Chapter 3. Unit-testing microservices

 

This chapter covers

  • Applying unit testing techniques in a microservices-based architecture
  • Deciding which tools fit best for writing unit tests
  • Understanding solitary versus sociable unit tests
  • Writing readable, robust unit tests

So far, you’ve become acquainted with the basic architecture, anatomy, and typical patterns used when developing microservices. You’ve also been introduced to the Gamer application, which is the reference application used throughout the book and for which we’ll now write some tests. In this chapter, you’ll learn how to write unit tests for a microservices-based architecture.

3.1. Unit testing techniques

As you now know, unit testing is a testing technique where the code of the application under test should be the smallest possible snippet to produce the required behavior. Another main characteristic of unit tests is that they should execute as quickly as possible, so developers get rapid feedback after any addition to or refactoring of the code base.

It’s important to remember that unit tests aren’t only a testing technique—unit testing is also a powerful design tool when you use a test-driven-development (TDD) approach, something we highly recommend.

3.2. Tools

3.3. Writing unit tests for the Gamer app

Exercises

Summary

sitemap