ArchUnit is a Java library for testing software architecture. It allows developers to express architectural constraints as automated tests, helping ensure that a codebase continues to follow its intended design as the application evolves.
The library examines compiled Java classes and constructs a representation of their relationships. Developers can then define rules governing dependencies, package organisation and interactions between different parts of an application.
ArchUnit is particularly valuable for large projects where architectural conventions can gradually deteriorate. A change that introduces an unwanted dependency or violates a layering rule can be detected during testing instead of remaining unnoticed until the codebase becomes difficult to maintain.
Architectural tests are written in Java using a fluent API. This makes them suitable for inclusion alongside existing unit tests and allows teams to express rules in a form that is both executable and relatively easy to understand.
This is free and open source software.
Key Features
- Analyses compiled Java bytecode to examine classes, packages, methods, fields and their dependencies.
- Checks dependencies between packages and classes against predefined architectural constraints.
- Enforces layered architectures by restricting interactions between application layers.
- Supports onion architecture rules for separating domain logic, application services and adapters.
- Detects cyclic dependencies between packages and architectural slices.
- Verifies class naming conventions and package organisation rules.
- Checks inheritance relationships, interface implementations and annotation requirements.
- Provides a fluent Java API for creating readable architectural tests.
- Supports custom conditions and predicates for application-specific architectural requirements.
- Includes module-oriented rules for examining boundaries and dependencies between logical application modules.
- Allows architecture rules to be grouped and reused across test classes.
- Provides integration with JUnit 4, JUnit 5 and JUnit 6.
- Supports caching imported classes to reduce repeated analysis during test execution.
- FreezingArchRule records existing violations and reports newly introduced violations, allowing gradual improvement of legacy codebases.
- Provides detailed violation reports identifying code that breaks architectural rules.
Website: github.com/TNG/ArchUnit
Support:
Developer: TNG Technology Consulting GmbH
License: Apache License 2.0
ArchUnit is written in Java. Learn Java with our recommended free books and free tutorials.
Related Software
| Java Linter Tools | |
|---|---|
| SpotBugs | Find bugs in Java code |
| PMD | Extensible cross-language static code analyzer |
| Error Prone | Catch common Java mistakes |
| NullAway | Eliminate NPEs in Java code |
| Infer | Static analysis tool for Java, C++, Objective-C, and C |
| Checkstyle | Write Java code that adheres to a coding standard |
| Checker Framework | Pluggable type-checking for Java |
| OpenRewrite | Automates large-scale source code refactoring and migration |
| Find Security Bugs | Detects security vulnerabilities in Java applications |
| Forbidden APIs | Checks Java code for prohibited or unsafe API usage |
Read our verdict in the software roundup.
LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more. Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion. Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README. |


Please read our Comment Policy before commenting.