More Related Content

Similar to Get with the Pact - Gotchas of Implementing Contract Testing the right way(20)


Get with the Pact - Gotchas of Implementing Contract Testing the right way

  1. GET/ with the Pact Gotchas of implementing Contract Testing the “right” way
  2. Bernardo Guerreiro Senior Engineer @ Auth0 Platform Team London, UK (Remote) 2 Twitter: @bernardobridge Medium:
  3. Workshop Requirements Do I need to know about Pact already? Nope. But it can’t hurt! Do I need a laptop? No. But you can follow with one! 3 Do I need to know Javascript? No. But it would help to understand some of the nuances. All concepts are transferable. @bernardobridge
  4. A Commit Story - The Movie 4 @bernardobridge
  5. 5 @bernardobridge
  6. Part 1 The Curious Case of the Missing Tests Uhm...someone “forgot” to write tests again @bernardobridge
  7. “ 7 @bernardobridge
  8. Part 2 Finding Testability FFS! Testing is hard. @bernardobridge
  9. “ 9 @bernardobridge
  10. Key Takeaways ▹ You need testability before you need Pact ▹ Work with developers to achieve that ▹ Mocking dependencies introduces a time related risk - you never know what’s still valid ▹ Integration Testing of Microservices can get very complicated very fast 10 @bernardobridge
  11. Part 3 The Dark Pact Contract Testing: a hero without a cape @bernardobridge
  12. “ 12 @bernardobridge
  13. Key Takeaways ▹ Pact works very similarly to existing mocking, but you are able to verify validity of the contract over time ▹ Your contracts should be as narrow as what your service actually consumes ▹ You can use Matchers to ensure your contracts are well suited ▹ Provider state allows you to inject data you may need to use to be able to replicate calls when verifying the provider ▹ Having consistent naming conventions is important to this workflow 13 @bernardobridge
  14. Part 4 V for Version My version is better than your version :P @bernardobridge
  15. “ 15 @bernardobridge
  16. Key Takeaways ▹ Pact pre-verifies versions for you when it knows the contract hasn’t changed and it had already been successfully verified ▹ Your provider version can’t just change when you release, as that’s too late in the release cycle ▹ You need your provider version to dynamically change with new code commits, so you can use commit sha’s ▹ Application Versions in the Pact world are about what code is running 16 @bernardobridge
  17. Part 5 The Instagram Principle Click here to tag your location @bernardobridge
  18. “ 18 @bernardobridge
  19. Key Takeaways ▹ If versions are about what piece of code is running, tags are about where it is running ▹ Branches are a natural candidate for where the code is running ▹ You can use consumerVersionTags to filter your provider verification results ▹ Think about the verification step triggered by the consumer, and the verification step from normal CI flow as different entities ▹ Make sure you are tagging the latest master Pact with a prod tag after releasing to prod. This lets you guarantee backwards compatibility 19 @bernardobridge
  20. Final Thoughts (you must be tired by now) @bernardobridge
  21. Getting Started: a few tips Run POC’s Proofs of Concept help establish confidence in the time/resource investment by demonstrating usefulness with minimal investment. Involve Tech Leads and Principals These people have a wide reach in the organization, and can help enforce/nail down implementation, proliferation and technical decisions. Involve SRE/DevOps A lot of the hurdles you will face will be about retrofitting this into a CI/CD pipeline. Get help from the experts in this area. You’ll need it! 21 Become a Champion Be the Champion for adoption of this tool, running workshops, brown bags, POC’s with teams, etc. Create RFC’s/equivalent RFC (Request for Comments) are a good way to centralise knowledge, clear doubts, but also to enforce conventions everyone can adopt. Get business buy-in This is not easy, but if business/product can understand the value of this, resource allocation and help become much easier to obtain. Pact works best if everyone uses it. It should be a company goal. @bernardobridge
  22. Useful Links Docs: Workshop Github Repo: Pact Foundation Slack Channel: UK Gov Lessons Learnt using Contract Testing: uk-pay/ Article I wrote about Authentication in Contract Testing: the-provider-51fd46fdaa78 Installing your Pact Broker on Heroku (outdated version, delete the Gemfile.lock to install more recent one): Atlassian Swagger/Pact Validator: 22
  23. THANKS! Any questions, please reach out! I’m happy to help. You can find me at: @bernardobridge 23