6 Testing frameworks, mocking, and dependencies

This chapter covers

  • Isolating code from external dependencies by using interfaces
  • Injecting dependencies into services to create composable portions of code
  • Constructing suites of tests to reduce boilerplate setup and teardown for tests
  • Stubbing and mocking dependencies to create isolated tests that are reliable
  • Simulating calls to an external service to test the logic of a client service

“So you want to sit with me and tell me what to code? Won’t that be a waste of your time?” You’ve just given the intern permission to access the repository and sat down next to her at her desk. You explain that she should download the repository and follow the directions on the README, and you will sit there ...

Get Shipping Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.