Understanding integration testing
What is an integration test? Integration tests test an application with its external dependencies by testing your application code's integration with concrete dependencies such as files, databases, and so on.
Integration tests take longer to execute because they often involve reading or writing to a database, but in return they give us more confidence in our application's health.
If a fast feedback loop from unit tests could send misleading results, I wouldn't mind writing a slow integration test that provides a correct outcome. A tricky feedback loop isn't worth the speed.
Enough about my opinions—let's start writing some integration tests and test all the commands and queries of our MediatR implementation.
Writing integration tests
Our first task is to create a new appsettings.json
file in the root folder of Application.IntegrationTests
. Copy the content of the Travel.WebApi
's appsettings.json
file...