用Test Container做 Integration Test

tech, practice

Integration Test #

Integration test is to test whether many separately developed modules work together as expected.

Image

narrow integration tests #

narrow integration tests are limited in scope, they often run very fast, so can run in early stages of a DeploymentPipeline, providing faster feedback should they go red.

broad integration tests #

Why Container Test #

https://www.testcontainers.org/ Test container allows you to combine the benefits of unit test with the benefits of containerization. It starts containers for you to run your Integration tests as a Unit Test.

Image

What does it do #

  1. start a container
  2. init test case data
  3. start service
  4. run junit
  5. assert

Furthermore #