Skip to content

TNG/ArchUnit

Repository files navigation

CIMaven CentralLicense

ArchUnit

ArchUnit is a free, simple and extensible library for checking the architecture of your Java code. That is, ArchUnit can check dependencies between packages and classes, layers and slices, check for cyclic dependencies and more. It does so by analyzing given Java bytecode, importing all classes into a Java code structure. ArchUnit's main focus is to automatically test architecture and coding rules, using any plain Java unit testing framework.

An Example

Add the Maven Central dependency to your project

Gradle
testImplementation 'com.tngtech.archunit:archunit:1.4.1' 
Maven
<dependency> <groupId>com.tngtech.archunit</groupId> <artifactId>archunit</artifactId> <version>1.4.1</version> <scope>test</scope> </dependency> 

Create a test

importcom.tngtech.archunit.core.domain.JavaClasses; importcom.tngtech.archunit.core.importer.ClassFileImporter; importcom.tngtech.archunit.lang.ArchRule; importstaticcom.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes; publicclassMyArchitectureTest{@Testpublicvoidsome_architecture_rule(){JavaClassesimportedClasses = newClassFileImporter().importPackages("com.myapp"); ArchRulerule = classes()... // see next sectionrule.check(importedClasses)} }

Let the API guide you

ArchUnit Fluent API

Where to look next

For further information, check out the user guide at http://archunit.org or test examples for the current release at ArchUnit Examples.

License

ArchUnit is published under the Apache License 2.0, see http://www.apache.org/licenses/LICENSE-2.0 for details.

It redistributes some third party libraries:

All licenses for ArchUnit and redistributed libraries can be found within the licenses folder.

About

A Java architecture test library, to specify and assert architecture rules in plain Java

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 84

Languages