@@Foad_Alavi, Thanks for your response. Plase see below: How to configure running integration tests in CI pipeline. How to handle side effects: e.g. Sending notifications: Call other services during the process:
Should we switch off side effects when running integration tests? Should we mock all the dependent services?
Should we run integration tests in our usual CI pipeline? Since it takes time to spin containers etc. Please provide your recommendations. Thanks in advance for your feedback.
I uploaded the first video about how to use it in Azure Pipeline. ruclips.net/video/7bBDOgVK8r4/видео.html Most of your questions will be answered in the second video, so do not miss them ;-)
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
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?
Well i think writing testauthhandler class that inherited from authenticationhandler and doing basic configuration would be fine but idk about if docker is changing the process.If auth was covered this video would be 10/10 as u say.
Good question. I haven't added this scenario to avoid making the project too complicated. For integration tests, I usually create a token, use this token in a fixture class, and use a method to add the auth token to the request header.
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.
Integration with an Azure CI pipeline would be a bit tricky, especially if you are using Linux based agents. I gave a presentation about how to do that in a development conference. I can create a short video about that if more people are interested about that. The technique that we can use for this is to use a docker wormhole.
I uploaded the first video about how to use it in Azure Pipeline. ruclips.net/video/7bBDOgVK8r4/видео.html In the following 2 videos, I will explain how it works and why we need to wrap our solution in a Docker image, so do not miss them ;-)
Im having a problem, the test runs perfectly but when the process finish, throws an error [Test Class Cleanup Failure (DatabaseProject.Test.Controllers.WithTestContainer)]: Docker.DotNet.DockerApiException : 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?
I'm sorry for not getting back to you sooner. I was busy with house renovation and got ill after that. I am not sure if it is correct. This interface in the GitHub repo is not marked as obsolete.
In integration testing, we do not really test the database; we test the boundaries of our application and check whether we can use the database. If you elaborate a bit more, I might be able to help you.
By making some changes to MsSqlContainer implementation, you can. I made the changes in this feature branch and used a custom database name, username, and password. github.com/foadalavi/Test-Foundation-playlist/tree/Feature/MsSqlContainer/Fix/IntegrationTest_Database If you want to change the server IP address, you need to create a network at the docker level, which is not straightforward.
I just added functionality to this feature branch o accept a file path to restore. You need to call 4 fluent methods: .WithDatabase("School") .WithPassword("$tr0ngP@$$w0rd") .WithUsername("MyUser") .WithRestore(@"C:\Users\foada\School.bak") The database name must be the name of the database you are going to restore. I hope it helps you.
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
I am glad it was useful
Thank you very much. Please list down all the challenges/pitfalls we gonna face with this approach.
Hi Ranga, thank you for your comments.
I explain three different approaches which of them do you mean specifically?
@@Foad_Alavi, Thanks for your response. Plase see below:
How to configure running integration tests in CI pipeline.
How to handle side effects:
e.g.
Sending notifications:
Call other services during the process:
Should we switch off side effects when running integration tests?
Should we mock all the dependent services?
Should we run integration tests in our usual CI pipeline? Since it takes time to spin containers etc.
Please provide your recommendations.
Thanks in advance for your feedback.
@@ransandu Hi Ranga, I will create a video and explain all your questions there
I uploaded the first video about how to use it in Azure Pipeline.
ruclips.net/video/7bBDOgVK8r4/видео.html
Most of your questions will be answered in the second video, so do not miss them ;-)
@@Foad_Alavi thanks. I'll surely watch it.
Thanks for your explanation. You are a wonderful teacher
Awesome, thanks! That would be good to cover authentication approaches for integration tests.
Great suggestion!
Awesome Explation, great tutorial for .net Developer
Another great demonstration and explanation. Thanks for sharing.
موفق باشی فواد 🤟
Thank you Foad. Amazing content.
My pleasure!
Thank you dude you helped me so much
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
You need to mock or remove the Auth services in WebApplicationFactory.
Thanks. Good info and nicely explained 😀
Very good explanation, Can you make it video for integration tests for cosmos db
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?
Well i think writing testauthhandler class that inherited from authenticationhandler and doing basic configuration would be fine but idk about if docker is changing the process.If auth was covered this video would be 10/10 as u say.
Good question.
I haven't added this scenario to avoid making the project too complicated.
For integration tests, I usually create a token, use this token in a fixture class, and use a method to add the auth token to the request header.
Amazing tutorial, thx for sharing
You’re welcome 😊
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.
Integration with an Azure CI pipeline would be a bit tricky, especially if you are using Linux based agents.
I gave a presentation about how to do that in a development conference. I can create a short video about that if more people are interested about that.
The technique that we can use for this is to use a docker wormhole.
@@Foad_Alavi maybe in github actions?
I uploaded the first video about how to use it in Azure Pipeline.
ruclips.net/video/7bBDOgVK8r4/видео.html
In the following 2 videos, I will explain how it works and why we need to wrap our solution in a Docker image, so do not miss them ;-)
@@Foad_Alavi thank you very very much
Is it possible to attach the debugger on the WebApiFactory so you can debug the api while run the tests?
Yes you can easily do that
Just put a break point in a place you need to debug
very well explained, Thank you
Glad it was helpful!
very useful video, thanks for that
Glad it was helpful!
Im having a problem, the test runs perfectly but when the process finish, throws an error [Test Class Cleanup Failure (DatabaseProject.Test.Controllers.WithTestContainer)]: Docker.DotNet.DockerApiException : 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?
I will try to check it today or tomorrow and see what can be the issue.
@@Foad_Alavi I come back to this video 8 months later and it finally works. I don't know what I did wrong last time
awesome!
Is IAsyncLifetime not been deprecated since 2021? Which benefit would this have over the more generic IDisposable?
I'm sorry for not getting back to you sooner. I was busy with house renovation and got ill after that.
I am not sure if it is correct. This interface in the GitHub repo is not marked as obsolete.
What if i have table with some constraints, for example Order has a column with foreign key ProductId, how to mock it
In integration testing, we do not really test the database; we test the boundaries of our application and check whether we can use the database.
If you elaborate a bit more, I might be able to help you.
great tutorial.
Glad you liked it!
Thanks for the video.
Good job !!!
Awesome🤞
more videos🔥
Excuse me but can i change the connection string?
By making some changes to MsSqlContainer implementation, you can.
I made the changes in this feature branch and used a custom database name, username, and password.
github.com/foadalavi/Test-Foundation-playlist/tree/Feature/MsSqlContainer/Fix/IntegrationTest_Database
If you want to change the server IP address, you need to create a network at the docker level, which is not straightforward.
@@Foad_Alavi thanks you saved me
can I restore a backup for exist database to test it?
I just added functionality to this feature branch o accept a file path to restore. You need to call 4 fluent methods:
.WithDatabase("School")
.WithPassword("$tr0ngP@$$w0rd")
.WithUsername("MyUser")
.WithRestore(@"C:\Users\foada\School.bak")
The database name must be the name of the database you are going to restore.
I hope it helps you.
@@Foad_Alavi i will try it thanks
45:40, wouldn't that cause a nasty memory leak in some situations? Doesn't make sense Docker uses the master for it.
Can you please elaborate more? What makes a memory leak?