All Articles

Testing

Sam Newman (2016), Building Microservices, O′Reilly.

Testing

The Test Pyramid outlines what types of automated tests you need.

  • Unit tests: test a single function or a method call
  • Service tests: bypass the user interface and test services direclty
  • End-to-End tests: run against your entire system

Trade-Offs

Coming back to the pyramid, the key thing to take away is that as you go up the pyramid, the test scope increases, as does our confifence that the functionality being tested works. However, the feedback cycle time increases as the tests take longer to run, and when a test fails it can be harder to determine which functionality has broken. As you go down the pyramid, in general the tests become much master, so we get much faster feedback cycles.

Favor of consimer-driven contracts over end-2-end tests

With CDCs, we define the expectations of a consumer on a service (or producer). The expectations of the consumers are captured in code form as tests, which are then run against the producer.

The goal of consumer-driven contacts is to provide focus points for conversations between teams.