Navigation Menu

Skip to content


Repository files navigation

CI Maven Central License


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

testImplementation 'com.tngtech.archunit:archunit:1.3.0'

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

Let the API guide you

ArchUnit Fluent API

Where to look next

For further information, check out the user guide at or test examples for the current release at ArchUnit Examples.


ArchUnit is published under the Apache License 2.0, see for details.

It redistributes some third party libraries:

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