Chapter 9. Testing microservices: Part 1

 

This chapter covers

  • Effective testing strategies for microservices
  • Using mocks and stubs to test a software element in isolation
  • Using the test pyramid to determine where to focus testing efforts
  • Unit testing the classes inside a service

FTGO, like many organizations, had adopted a traditional approach to testing. Testing is primarily an activity that happens after development. The FTGO developers throw their code over a wall to the QA team, who verify that the software works as expected. What’s more, most of their testing is done manually. Sadly, this approach to testing is broken—for two reasons:

  • Manual testing is extremely inefficient You should never ask a human to do what a machine can do better. Compared to machines, humans are slow and can’t work 24/7. You won’t be able to deliver software rapidly and safely if you rely on manual testing. It’s essential that you write automated tests.
  • Testing is done far too late in the delivery process There certainly is a role for tests that critique an application after it’s been written, but experience has shown that those tests are insufficient. A much better approach is for developers to write automated tests as part of development. It improves their productivity because, for example, they’ll have tests that provide immediate feedback while editing code.

9.1. Testing strategies for microservice architectures

9.2. Writing unit tests for a service

Summary

sitemap