5 Architecture Tests You Should Add to Your .NET Projects
This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).
Architecture rules documented only in wikis will eventually be violated. Using ArchUnitNET, you can encode those rules as automated tests that run in CI. Five test categories are covered: layer dependency tests (enforcing Clean Architecture's dependency rule), naming convention tests (ensuring handlers and validators follow consistent naming), colocation tests (verifying CQRS command/handler pairs live in the same namespace using raw reflection), visibility tests (enforcing that handlers are internal rather than public), and dependency guard tests (preventing infrastructure libraries like EF Core from leaking into Domain or Application layers). Setup requires a base class that loads all project assemblies, and all tests run in milliseconds without any infrastructure.
Table of contents
ArchUnitNET and the Test Setup1. Layer Dependency Tests2. Naming Convention Tests3. Colocation Tests4. Visibility Tests5. Dependency Guard TestsSummarySort: