Unit Test Your Java Architecture With ArchUnit
summary
ArchUnit is used to analyzes Java bytecode and enforce concrete rules: controllers annotated with @Controller must have names ending with Controller, owner and vet packages must not depend on each other, and module/package cycles are detectable. It integrates with JUnit 4/5, can be packaged as a shared rules library, and extends via custom conditions (example: methods with @PostMapping must call an SLF4J logger). For legacy bases it supports a freeze current violations file (demo shows five immediate violations but warns real projects can have hundreds), and Spring Modulith and jMolecules interoperate.
AI-written summary · about
chapters (14)
- 0:00Introduction and setup
- 9:21First ArchUnit rule demo
- 15:00Module dependency rules
- 17:12Standard rule sets and Spring
- 21:48Reusable rules across projects
- 25:03Detecting module cycles
- 27:13Spring Modulith comparison
- 28:37ArchUnit and bytecode analysis
- 29:20Legacy code integration
- 33:57Freezing violations for gradual fixes
- 37:16Adding new violations after freezing
- 38:00Detecting logging requirements
- 39:06Hexagonal architecture with JMolecules
- 41:57Architecture as code summary
related talks
43mUnit Test Your Java Architecture With ArchUnit
52mArchUnit - Unit Testing Architecture and Design
24mUnit Testing Your Architecture
49mArchUnit: Guarding the Logic of Your Application
22mArchitecture & ArchUnit
42mArchitecture testing with ArchUnit: Implementation for DDD
49mJava's Hidden Gems: Tools and Libraries
41mSoftware Architecture — Yes, on Tests
