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

Testing Reconsidered

Testing Reconsidered

Given an opportunity to work on a green fields project, a team that I worked closely with challenged our current monolithic testing practices and attempted to follow a new tactical approach more suitable for the added complexity of shifting to micro services.

This is a story of how we attempted to implemented a continuous delivery pipeline that got us very close to the utopia of deploying every single commit to production at a click of a button. We've had to challenge the way we think and talk about tests, and most certainly the way that we write them. More focus on smaller and concise unit tests, integration tests that stop strictly short at boundaries, and the blurring of the boundaries between what should be covered by developers and testers.

Hady Osman

March 28, 2017
Tweet

More Decks by Hady Osman

Other Decks in Programming

Transcript

  1. Key Takeaways: 1. Contract Driven Testing 2. Combination of testing

    strategies leads to a high test coverage 3. Everyone is responsible for testing
  2. Continuous Delivery Image Reference: http://www.theimaginativeconservative.org Continuous delivery is a series

    of practices designed to ensure that code can be rapidly and safely deployed to production by delivering every change to a production-like environment and ensuring business applications and services function as expected through rigorous automated testing.
  3. With shift to “micro” services Monolithic testing practices need to

    be reconsidered Image Reference: http://www.bbc.com/earth/story/20170127-how-to-d ecide-which-extinct-species-we-should-resurrect Need new approaches for managing additional complexity: • Multiple independently deployable components • Scale and maintain each component • Multiple teams acting as guardians for different services
  4. Consumer Driven Contracts Service Provider (Client Service) Consumer (Client Web)

    Consumer (Activity Web) Implementation Boundary Remote Boundary Apiary API Blueprint Swagger Illustrations based on: http://thoughtworks.github.io/pacto/patterns/cdc/
  5. Consumer Driven Contracts Service Provider (Client Service) Consumer (Client Web)

    Consumer (Activity Web) Implementation Boundary Remote Boundary Contract testing tools to guarantee fulfillment (e.g. Pact, Chappie) Stub Service Illustrations based on: http://thoughtworks.github.io/pacto/patterns/cdc/
  6. Resources Service Layer Domain Repositories HTTP Client Data Mapper /

    ORM External Datastore External Service Illustration Reference: https://martinfowler.com/articles/micr oservice-testing/#anatomy-modules
  7. Resources Service Layer Domain Repositories HTTP Client Data Mapper /

    ORM External Datastore External Service Unit Testing • Typically written at a class level, or a function level • Avoid mocks • Need for mocks highlight when a module should be broken • Powerful design tool • Does NOT test state changes
  8. Execute(List events) { events .Where(IsPartnerSwap) .Select(Transform) .ForEach(Create); } private IsPartnerSwap(event)

    { ... } private Transform(event) { ... } private Create(practice) { ... } public public public But not on interface
  9. Resources Service Layer Domain Repositories HTTP Client Data Mapper /

    ORM External Datastore External Service Integration Testing • Full microservice in-memory (OWIN) • Using real DB and SP’s • All interactions make use of real network calls • Test double help emulate unhappy paths • FED - Use a real browser on build agents Component Stub Service Pact spins up a real server to act as a test double Each test specifies pre-defined responses
  10. A combination of testing strategies leads to a high test

    coverage Image: https://martinfowler.com/articles/microservice-testing/#conclusion-test-pyramid
  11. You will be shipping bugs Mitigated by monitoring and fast

    deployment pipeline for rollback/rollforward
  12. No team member to be left out of the journey

    Shared understanding of the stack cultivates shared ownership
  13. Key Takeaways: 1. Contract Driven Testing 2. Combination of testing

    strategies leads to a high test coverage 3. Everyone is responsible for testing