Master ASP.NET Core Integration Testing: Learn How TestContainers and WebApplicationFactory Can Help

preview_player
Показать описание
In this video, we dive into the world of integration testing for ASP.NET Core WebAPI against a database using WebApplicationFactory and TestContainers.

⏱️⏱️VIDEO CHAPTERS⏱️⏱️
00:00 - Intro
00:13 - Microsoft documentation
01:37 - Test Server with TestApplicationFactory
19:30 - IClassFixture
21:46 - Test Environment
23:13 - IAsyncLifetime
24:16 - Bogus to fake data
32:34 - TestContainers

Throughout the video, we explore the utilization of the WebApplicationFactory to effectively run a test server and demonstrate the implementation of dependency injection for utilizing an in-memory database. We also discuss the importance of testing a database in a test environment and delve into the benefits of Docker-based testing with TestContainers, eliminating the need for a dedicated test environment.
Furthermore, we cover the utilization of the IClassFixture interface to seamlessly share the test context between methods within a test class and demonstrate how to manage the lifecycle of a test using IAsyncLifetime.
To enhance the authenticity of the data used, we showcase the implementation of bogus, a powerful tool for generating meaningful fake data.
Join us as we provide step-by-step guidance on mastering ASP.NET integration testing, leveraging the capabilities of TestContainers and Web Application Factory. Improve your understanding of integration testing and optimize the reliability and efficiency of your ASP.NET Core WebAPI using xUnit.

#testing #csharp #dotnet #integrationtesting #TestContainer #webapi
Рекомендации по теме
Комментарии
Автор

you saved my ass i have been trying to get integration tests running for 6 hours and after your video everything worked THANK YOU SO MUCH

palandorent
Автор

Thank you very much. Please list down all the challenges/pitfalls we gonna face with this approach.

ransandu
Автор

Thanks for your explanation. You are a wonderful teacher

qasimmughal
Автор

Awesome, thanks! That would be good to cover authentication approaches for integration tests.

tomaszbaginski
Автор

Awesome Explation, great tutorial for .net Developer

raj
Автор

Thanks. Good info and nicely explained 😀

rohanwankhede
Автор

Another great demonstration and explanation. Thanks for sharing.

hesamkalhor
Автор

Very good explanation, Can you make it video for integration tests for cosmos db

ravikirangutti
Автор

What's often not covered by these tutorials is auth. How do you integration test your API with oauth token protection? Because more often than not your API is behind some auth and you also want to ensure that it's protected as expected.

Do you:
1) Generate a real token and use it for all tests?
2) Mock it?
3) Other?

PelFox
Автор

Thanks for this nice video. I checked your other videos but I couldn't see any video how we can configure running integration tests in CI pipeline with TestContainers.

BarbarosYurttagul
Автор

Hi, thanks for the video, exactly what I was looking for using testContainers, one question how can you handle the API Authentication if the API is [Authorize] with Azure AD ? thanks

nandotox
Автор

Is IAsyncLifetime not been deprecated since 2021? Which benefit would this have over the more generic IDisposable?

jensingels
Автор

Is it possible to attach the debugger on the WebApiFactory so you can debug the api while run the tests?

thiagoclassen
Автор

What if i have table with some constraints, for example Order has a column with foreign key ProductId, how to mock it

BartoszSeweryn-hp
Автор

Im having a problem, the test runs perfectly but when the process finish, throws an error [Test Class Cleanup Failure : Docker API responded with status code=InternalServerError, response={"message":"cannot remove container \"/boring_tu\": could not kill: container a9991e425e3a PID 8972 is zombie and can not be killed. Use the --init option when creating containers to run an init inside the container that forwards signals and reaps processes"}. Any ideas?

andresbeltran
Автор

45:40, wouldn't that cause a nasty memory leak in some situations? Doesn't make sense Docker uses the master for it.

jensingels
Автор

Excuse me but can i change the connection string?

nagwaahmed
join shbcf.ru