ArchUnit

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

  • Owner: TNG/ArchUnit
  • Platform:
  • License:: Apache License 2.0
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

Build Status
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

Gradle
testCompile 'com.tngtech.archunit:archunit:0.13.0'
Maven
<dependency>
    <groupId>com.tngtech.archunit</groupId>
    <artifactId>archunit</artifactId>
    <version>0.13.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.

Main metrics

Overview
Name With OwnerTNG/ArchUnit
Primary LanguageJava
Program languageJava (Language Count: 2)
Platform
License:Apache License 2.0
所有者活动
Created At2017-04-21 08:39:20
Pushed At2025-06-17 06:06:56
Last Commit At
Release Count43
Last Release Namev1.3.2 (Posted on )
First Release Namev0.4.0 (Posted on )
用户参与
Stargazers Count3.4k
Watchers Count51
Fork Count316
Commits Count2.5k
Has Issues Enabled
Issues Count590
Issue Open Count128
Pull Requests Count550
Pull Requests Open Count17
Pull Requests Close Count264
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private