Testing your Software Architecture

Architectural Unit Testing

  • Code Organization. Let’s say you have a team agreement that states, “All repositories must exist within a package that ends with the name .repository
  • Static coupling/dependencies between the different elements of your program, such as functions, types, packages, modules, components, libraries and frameworks. You can test things like cyclic dependencies, dependence on third-parties, proper use of anti-corruption layers, etc.
  • Architectural style. Your team might have agreed on some layered architect, maybe you’re using the ports and adapters.
  • Cross-cutting concerns. You might want to enforce that ‘Services’ within your codebase are properly annotated with @Secured or that all the public methods in Services log at least once.

Example Tests

A Java Layered Architecture

All .NET Core Services should be authorized

TypeScript business logic should not depend on the frontend

All .NET Core public methods must be tested (Custom Condition)

Other Architectural Testing Techniques

  • Using a static code analysis tool like SonarQube to enforce code style rules. (Maintainability)
  • Using software package metrics to gather objective data about your codebase, then enforcing rules in some build pipeline. (Maintainability)
  • Employing Chaos Engineering tactics to validate your architecture at run time. (Reliability/Compatibility)
  • Automated penetration testing on all your microservices. (Security)
  • Using Lighthouse to detect problems with your web frontend. (Usability)
  • Performing automated load/stress/performance tests with k6 or JMeter. (Performance/Reliability)
  • Etc... You can enforce many architectural requirements by making use of fitness functions.


Connect with me ❤



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ryan Susana

Ryan Susana

I like code, chess, reggae & hip-hop. 🇸🇽