A Java architecture test library, to specify and assert architecture rules in plain Java
Java
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
archunit-example Added 'onlyDependOnClassesThat(predicate?)' to the rules API. Aug 18, 2018
archunit-integration-test Added 'onlyDependOnClassesThat(predicate?)' to the rules API. Aug 18, 2018
archunit-junit JavaDoc and SourcesJar have to be configured individually for JUnit 4… Aug 19, 2018
archunit-maven-test JUnit 4 support now allows instance fields of all types of visibility… Aug 12, 2018
archunit Added 'onlyDependOnClassesThat(predicate?)' to the rules API. Aug 18, 2018
build-steps Adjusted automatic ArchUnit-Example update to include 3 sets of examp… Aug 19, 2018
ci Added a simple Windows CI setup. Docker-Image for an ArchUnit master … Jan 6, 2018
develop Added CONTRIBUTING.md and code formatters. Also reformatted all code … Sep 17, 2017
docs Fixed some forgotten references to old artifact archunit-junit in use… Aug 19, 2018
gradle/wrapper Step 3.4 - Added discovery of @tag. Unfortunately, the @target of @tag Aug 3, 2018
licenses Renamed license and contributing related files to be consistent with … May 5, 2018
logo Added Icon + twitter graphics Dec 28, 2017
.gitignore Added condition to evaluate PlantUml diagrams as rules. Also stereoty… Aug 8, 2018
.travis.yml Remove --info for Travis to reduce the log size (otherwise the build … Aug 18, 2018
ArchUnit-API.gif Added TL;DR section to the beginning of README.md, to get a quicker s… Apr 23, 2017
CONTRIBUTING.md Updated CONTRIBUTING.md -> we don't need the reference to "ArchUnit C… Jul 6, 2018
DCO Renamed license and contributing related files to be consistent with … May 5, 2018
LICENSE Renamed license and contributing related files to be consistent with … May 5, 2018
NOTICE Renamed license and contributing related files to be consistent with … May 5, 2018
README.md Update README.md to 0.9.0 Aug 19, 2018
build.gradle Shadow-Jar was configured incorrectly -> api and engine-api had too m… Aug 5, 2018
gradle.properties Activate parallel builds Jun 19, 2017
gradlew Upgradle to 4.0 Jun 17, 2017
gradlew.bat Upgradle to 4.0 Jun 17, 2017
icon.png icon for SourceTree git client Dec 8, 2017
settings.gradle Step 5.3: Moved source sets to different Gradle modules, since it see… Aug 4, 2018

README.md

Build Status Maven Central License

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
testCompile 'com.tngtech.archunit:archunit:0.9.0'
Maven
<dependency>
    <groupId>com.tngtech.archunit</groupId>
    <artifactId>archunit</artifactId>
    <version>0.9.0</version>
    <scope>test</scope>
</dependency>

Create a test

import com.tngtech.archunit.core.domain.JavaClasses;
import com.tngtech.archunit.core.importer.ClassFileImporter;
import com.tngtech.archunit.lang.ArchRule;

import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes;

public class MyArchitectureTest {
    @Test
    public void some_architecture_rule() {
        JavaClasses importedClasses = new ClassFileImporter().importPackages("com.myapp");
    
        ArchRule rule = classes()... // see next section
    
        rule.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.