Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Power of Architectural Testing

The Power of Architectural Testing

It’s 2018. Nowadays we are used to striving for agility and we exploit automation to stay responsive in our ability to adapt to change. We write tons of unit, integration and system tests as equal part of our production code, to ensure functional correctness. We make use of powerful linters to get and retain a high level of internal code quality. We let continuous integration servers execute those tests and checks on every single commit, to get a fast feedback for our highly iterative development process.

That’s really cool, isn‘t it?

Not quite. What about architecture? The layers? The component model? The dependency rules? The 10,000 ft birds view?

We often don’t care and, even more often, don’t check those very relevant, structural aspects of extensibility and maintainability.

In a perfect world we’d have architectural tests, that can be easily defined, executed and integrated in our continuous integration process along with all the other automatic tests and checks we know and love.

Armin Weißer

November 27, 2018
Tweet

More Decks by Armin Weißer

Other Decks in Programming

Transcript

  1. Ability to adapt to C H A N G E

    Test Automation Build Automation Clean Code Proper Architecture *Icons made by Freepik and Smartline from www.flaticon.com
  2. Test Automation Unit Tests Verify each software component. Integration Tests

    Verify the interactions between components. System Tests Verify the fully integrated system. Performance/Load/Security Tests Verify non-functional requirements. *Icon made by Freepik from www.flaticon.com
  3. Build Automation: Let the CI/CD pipe do all the work!

    *Icon made by Freepik from www.flaticon.com
  4. Layer 2 Layer 1 *Icon made by Smartline from www.flaticon.com

    Proper Architecture Component Component Component Dependency Dependency Dependency
  5. Are we now able to cope with C H A

    N G E ? Test Automation Build Automation Clean Code Proper Architecture *Icons made by Freepik and Smartline from www.flaticon.com
  6. Layer 2 Layer 1 *Icon made by Smartline from www.flaticon.com

    Architectural Erosion Component Component Component Component Component Component
  7. *Icon made by Smartline from www.flaticon.com Architectural Style Ordering Shipping

    REST-API EMAIL MySQL IO CORE Dependency Rules * → CORE && not( IO → IO ) && not( CORE → IO )
  8. // 1. Choose your architectural style var archStyle = new

    CleanArchLight("Petshop"); // 2. Identify and parse all components and dependencies in your solution. var petshopSolution = Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace .Create() .OpenSolutionAsync("Petshop.sln") .Result; var dependencies = new DependencyCollector(archStyle).Collect(petshopSolution); // 3. Check for invalid component dependencies. var checkedDependencies = DependencyCheck .WithDependencies(dependencies) .WithRule(archStyle) .Result(); // 4. Assert that all dependencies are allowed Assert.That(checkedDependencies.AllDependenciesAllowed, Is.True, "There are invalid dependencies in your code!"); https://gitlab.com/iternity/archlint.cs
  9. Ability to adapt to C H A N G E

    Test Automation incl. Architectural Tests Build Automation Clean Code Proper Architecture *Icons made by Freepik and Smartline from www.flaticon.com
  10. References ▪ archlint.cs for .NET – by iTernity GmbH https://gitlab.com/iternity/archlint.cs

    ▪ plantuml.cs for .NET – by iTernity GmbH https://gitlab.com/iternity/plantuml.cs ▪ ArchUnit for Java – by TNG Technology Consulting GmbH https://github.com/TNG/ArchUnit ▪ The Clean Architecture – by Robert C. Martin https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html TEST YOUR ARCHITECTURE 111Einself!!!