Post

.Net 8 (C#) REST Api integration testing with TestContainer (instead of docker compose)

Introduction

TestContainers is an open-source library that simplifies the process of running integration tests by providing lightweight, disposable instances of databases, message brokers, APIs, web browsers, and other services within Docker containers. 

This allows developers to test their applications with real dependencies, ensuring more accurate and reliable test results compared to using mocks or in-memory substitutes.

Why use Testcontainers with .Net?

  1. Testcontainers are easier to integrate into test code in languages like Java, C# over docker compose and provides more streamlined approach for testing.
  2. Testcontainers use docker internally to run the test cases and simplifies the usage and configurations required for docker compose.

Prerequisites

  1. Docker desktop
  2. .Net 8 application

Steps

Follow / clone the github repo to test it

References

This post is licensed under CC BY 4.0 by the author.