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.
Latest public signals
Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.
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
- Architecture as tests: Rules run in your normal unit test suite.
- Layer and cycle checks: Layered, onion and slice rules built in.
- Freezing: Accept existing violations and block new ones.
- JUnit integration:
@AnalyzeClassesand@ArchTestwith caching.
Pros
- Free to use: Open source under the Apache-2.0 licence, so the core tool costs nothing to use.
- Actively maintained: The repository had commits as recent as 11 November 2026.
- Community: About 3,900 GitHub stars.
Cons
- Bytecode-level: Rules apply to compiled classes, not source formatting.
- Rule design effort: Teams must agree which rules matter.
Usage and Links (Example)
@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.
Recommended for?
- Java and Kotlin teams wanting to enforce architecture boundaries automatically.
- 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.
JJUnit 5JUnit 5 is the current JUnit for Java and the JVM: Jupiter for new tests, Platform to launch them, Vintage to run JUnit 4.Compare with ArchUnit
TTestNGTestNG is an Apache-2.0 testing framework for Java, inspired by JUnit and NUnit, with annotations, groups, dependencies, data providers, parallel execution and XML suite configuration; it requires Java 11+.Compare with ArchUnit
SSonarQubeModernize your AI workflows with code verification for the agentic era.Compare with ArchUnit
AAssertJAssertJ is an Apache-2.0 fluent assertions library for Java, with rich, discoverable assertions for core types, collections, exceptions, dates and more, plus soft assertions and custom assertion generation.Compare with ArchUnit
PPestPest is an MIT-licensed PHP testing framework built on PHPUnit with an expressive, closure-based API; Pest 5 (PHP 8.4+, PHPUnit 13) adds the Tia engine, an agent plugin, evals, PHPStan and Rector support.Compare with ArchUnit
SSpock FrameworkSpock is an Apache-2.0 BDD-style testing and specification framework for Java and Groovy applications, with given/when/then blocks, powerful data-driven tests and built-in mocking, running on the JUnit Platform.Compare with ArchUnit