The Best Way To Use Docker For Integration Testing In .NET
📌 Check out my Pragmatic Clean Architecture course: https://www.milanjovanovic.tech/pragmatic-clean-architecture
🚀 Support me on Patreon to access the source code: https://www.patreon.com/milanjovanovic
Integration testing is a testing approach that tests the integration between multiple components. Usually, this will involve a database, so you can test your query logic. Docker is an excellent tool for creating throwaway databases for your integration tests. And you can make it even better with the Testconatiners library. It allows you to programmatically create your docker containers for integration testing.
Join my weekly .NET newsletter:
https://www.milanjovanovic.tech
Read my Blog here:
https://www.milanjovanovic.tech/blog
Subscribe for more:
https://www.youtube.com/@MilanJovanovicTech
Chapters:
0:00 Creating the test project and installing Testcontainers
1:55 Implementing a custom WebApplicationFactory
6:11 Adding a PostgreSQL container with Testcontainers
8:15 Creating the base integration test class
9:57 Integration test 1: Creating a product with exception
13:10 Integration test 2: Creating a product and validating in the database
16:13 Integration test 3: Getting a product by the ID
Comments are closed.