concept unit test in category docker

appears as: unit test, unit tests
Bootstrapping Microservices with Docker, Kubernetes and Terraform

This is an excerpt from Manning's book Bootstrapping Microservices with Docker, Kubernetes and Terraform.

Building with microservices is one such tool for managing complexity. Any given microservices should be simple. It should be small. Making a small update to an existing microservice should be easy. Adding a new microservice to an existing application should be easy. These statements are true even once the application itself has become extremely complex.

Unit testing for microservices works the same as any other kind of unit testing. We are aiming to test a single unit of code by itself and in isolation from other code. What is a unit? Typically each test exercises a single function or one aspect of a single function.

Listing 8.8 - A helper function to load a database fixture (extract from chapter-8/example-3/src/index.test.js)
// ...
 
async function loadDatabaseFixture(collectionName, records) { #A
    await microservice.db.dropDatabase(); #B
 
    const collection = microservice.db.collection(collectionName);
    await collection.insertMany(records); #C
}
 
// ...