Skip to content
/ ArchUnit Public

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

License

Notifications You must be signed in to change notification settings

TNG/ArchUnit

Folders and files

NameName
Last commit message
Last commit date
Apr 9, 2025
Jun 9, 2024
Jun 9, 2024
Jun 9, 2024
Jun 9, 2024
Jan 19, 2025
Apr 9, 2024
Feb 10, 2025
Apr 11, 2024
Jan 20, 2025
Nov 5, 2023
Mar 22, 2025
Feb 26, 2025
May 5, 2018
Dec 28, 2017
Feb 20, 2022
Feb 12, 2022
Apr 23, 2017
Feb 2, 2023
May 5, 2018
May 5, 2018
Apr 9, 2024
Feb 10, 2025
Apr 8, 2025
Feb 10, 2025
Feb 26, 2025
Jan 19, 2025
Dec 8, 2017
Feb 20, 2025

Repository files navigation

CI 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
testImplementation 'com.tngtech.archunit:archunit:1.4.0'
Maven
<dependency>
    <groupId>com.tngtech.archunit</groupId>
    <artifactId>archunit</artifactId>
    <version>1.4.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.