liveBook · Manning

Unit test

As explained in Microservices Patterns, Second Edition

A unit test verifies a small, isolated unit of software behavior, typically executing quickly within a local development environment.

A unit test checks non-trivial code in memory, such as an algorithm or business logic. Isolating behavior can replace slower integration tests that require infrastructure services. section 5.4.4 section 6.2.5

In a modular monolith, keep tests focused at the appropriate level:

  • Unit-test domain behavior, such as an Order entity; use integration tests for adapters and module tests for the whole module. section 6.2.5
  • Use dependency injection to provide a mock data-access object, or test dependency-free functional business logic directly. section 5.4.4

How Microservices Patterns, Second Edition covers it

How deep it goes
Defines in-memory tests for non-trivial code and distinguishes them from adapter integration tests and whole-module tests.
Examples
Tests an Order entity, algorithms, and dependency-free business logic in memory.
What you can do after
Evaluate non-trivial code behavior in memory without relying on heavyweight infrastructure services.
How it connects
Connects unit testing with dependency injection, functional programming, integration testing, and test doubles.

Also explained in

Compare how 18 books explain unit test →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.