CheckOps home

Tools directory

A

CheckOps

ArchUnit

ArchUnit is an Apache-2.0 Java library for checking architecture rules (layers, dependencies, cycles, naming) as ordinary unit tests with any plain Java unit testing framework.

Visit website

Latest public signals

Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.

Visit Website

Introduction

ArchUnit is a free, simple and extensible library for checking the architecture of Java code with any plain Java unit test framework. It analyses compiled Java bytecode and lets you assert rules about packages, classes, layers and dependencies, so architectural decisions are enforced automatically in CI rather than living only in documents.

Rules are written with a fluent API, for example noClasses().that().resideInAPackage("..service..").should().dependOnClassesThat().resideInAPackage("..controller.."). Built-in helpers check layered architectures (layeredArchitecture()), onion architectures, slices that must be free of cycles, and coding rules such as “no field injection” or “no use of java.util.logging”. JUnit 4 and JUnit 5 integrations provide @AnalyzeClasses and @ArchTest with class caching, and the “freezing” feature records existing violations so you can adopt rules on legacy code and fail only on new ones. It works with Kotlin and other JVM languages compiled to bytecode. ArchUnit is developed by TNG; v1.5.1 was released on 25 September 2026.

The source code is at TNG/ArchUnit on GitHub under the Apache-2.0 licence, with about 3,900 stars; the most recent commit was on 11 November 2026.

Features

  1. Architecture as tests: Rules run in your normal unit test suite.
  2. Layer and cycle checks: Layered, onion and slice rules built in.
  3. Freezing: Accept existing violations and block new ones.
  4. JUnit integration: @AnalyzeClasses and @ArchTest with caching.

Pros

  1. Free to use: Open source under the Apache-2.0 licence, so the core tool costs nothing to use.
  2. Actively maintained: The repository had commits as recent as 11 November 2026.
  3. Community: About 3,900 GitHub stars.

Cons

  1. Bytecode-level: Rules apply to compiled classes, not source formatting.
  2. Rule design effort: Teams must agree which rules matter.
@AnalyzeClasses(packages = "com.example.shop")
class ArchitectureTest {

    @ArchTest
    static final ArchRule layers = layeredArchitecture().consideringAllDependencies()
        .layer("Controller").definedBy("..controller..")
        .layer("Service").definedBy("..service..")
        .layer("Persistence").definedBy("..repository..")
        .whereLayer("Controller").mayNotBeAccessedByAnyLayer()
        .whereLayer("Service").mayOnlyBeAccessedByLayers("Controller")
        .whereLayer("Persistence").mayOnlyBeAccessedByLayers("Service");

    @ArchTest
    static final ArchRule noCycles =
        slices().matching("com.example.shop.(*)..").should().beFreeOfCycles();
}

Resources:

Pricing

ArchUnit is free and open source under the Apache-2.0 licence.

  1. Java and Kotlin teams wanting to enforce architecture boundaries automatically.
  2. Legacy codebases, using freezing to stop architecture erosion.

Conclusion

ArchUnit turns architecture guidelines into fast, automated tests, one of the most effective ways to prevent gradual design decay on the JVM.

Alternatives

Other tools on CheckOps that cover similar ground. Open a page, or compare one with ArchUnit side by side.