Docker Desktop is not free for business environment, and installing Docker runtime alone outside of Destop is a hack that many would hate to follow through. It ain't as convenient as may seem. Starting Docker containers is slow as heck. However, there is much better way using Docker DB image, and that is create your own with all the schema and all data already created and then merely start that image instead of applying migrations every time you run tests. There is another inconvenience in updating dB Docker image when new schema changes are needed. It all depends on usage context.
Docker is slow on Windows and macOS due to been a virtual machine per se. A free alternative for commercial usage is "Rancher desktop", That's what I'm using in my current job
podman is fine. Respawner is also intersting. With testcontainer and respawner i got integrationstest to take less than 100 ms, which is okay. Creating a new container for each test seems excessive.
Hi Milan, thanks for sharing, and keep me informed with new tech and approaches. I have hundreds of int tests in my project and they "sometimes" impact to each other, because of shared data. Example: test checks that all active documents are been deleted, but asynchronously another test running is creating active document same time for its case. Any idea how to handle that? Tests are created by the team continuesly.
We can mitigate this (somewhat) with an ICollectionFixture - only create one database container and use it for all tests. This will require more careful test cleanup.
@@MilanJovanovicTech, some docker images, such as the CosmosDb Emulator, are slow even for that. ICollectionFixture is a good solution for some cases, but the problem is parallel running and commands.
@@rodjenihm No, it's not possible by definition. If you have a transaction in ACID-style DB, it has to be finished entirely before anything can read or modify that data.
Hello, how are you? Your videos are great and provide good tips for improving your skills. I saw that you uploaded a video with the audio track feature. You could continue uploading it with this feature. It makes it even easier to absorb content in my native language and learn more and more. Thank you, and have a great New Year.
Your videos are great, but they feel a bit scattered. Could you please create a playlist to organize them in one place? This would make it easier to find and watch videos meaningfully.
I don't know why microsoft want to go for a way different of the other languages with a specific way to run docker container. I really don't understand why this is a better solution than a docker-compose file...
Well you can technically also docker-compose for tests - but you'd have to run it manually before running the tests. Also you have to set up the connection strings yourself, etc.
While testcontainer tests can be useful, you can continue mocking your database (the secondary adapter). Testcontainer tests still are too slow compared to tests inmmemory.
Want to master Clean Architecture? Go here: bit.ly/3PupkOJ
Want to unlock Modular Monoliths? Go here: bit.ly/3SXlzSt
This is a great method for testing when adding additional logic to projects in production.
Thanks, Milan, keep up the good work.
Much appreciated!
Respawn library is a great addition to Integration Tests for intelligent database cleanup after running each test
Nice!
Docker Desktop is not free for business environment, and installing Docker runtime alone outside of Destop is a hack that many would hate to follow through. It ain't as convenient as may seem. Starting Docker containers is slow as heck. However, there is much better way using Docker DB image, and that is create your own with all the schema and all data already created and then merely start that image instead of applying migrations every time you run tests. There is another inconvenience in updating dB Docker image when new schema changes are needed. It all depends on usage context.
Docker is slow on Windows and macOS due to been a virtual machine per se. A free alternative for commercial usage is "Rancher desktop", That's what I'm using in my current job
As you mentioned, a custom image may be appropriate if and when your schema has stabilized significantly as it adds significant overhead.
Podman is an option 👍
There are other ways to run containers. Might be a good topic to explore in this year's videos
podman is fine.
Respawner is also intersting. With testcontainer and respawner i got integrationstest to take less than 100 ms, which is okay. Creating a new container for each test seems excessive.
What a way to finish 2024. Happy new year, Milan :)
Happy New Year!
Hi Milan, thanks for sharing, and keep me informed with new tech and approaches. I have hundreds of int tests in my project and they "sometimes" impact to each other, because of shared data. Example: test checks that all active documents are been deleted, but asynchronously another test running is creating active document same time for its case. Any idea how to handle that? Tests are created by the team continuesly.
in Development , how to use Docker with DBUP to seed data ?
The only problem is that it takes some time to initialize the Docker, especially for some databases.
We can mitigate this (somewhat) with an ICollectionFixture - only create one database container and use it for all tests. This will require more careful test cleanup.
@@MilanJovanovicTech Isn't it possible to just run every test in transaction that rolls back automatically in the end?
@@rodjenihm Technically, yes. Haven't used that approach in practice. Any caveats you've encountered?
@@MilanJovanovicTech, some docker images, such as the CosmosDb Emulator, are slow even for that. ICollectionFixture is a good solution for some cases, but the problem is parallel running and commands.
@@rodjenihm No, it's not possible by definition. If you have a transaction in ACID-style DB, it has to be finished entirely before anything can read or modify that data.
Hello, how are you? Your videos are great and provide good tips for improving your skills. I saw that you uploaded a video with the audio track feature. You could continue uploading it with this feature. It makes it even easier to absorb content in my native language and learn more and more. Thank you, and have a great New Year.
That's a recent YT feature, I'm glad you enjoy it :)
Your videos are great, but they feel a bit scattered. Could you please create a playlist to organize them in one place? This would make it easier to find and watch videos meaningfully.
I'm working on a platform to connect them!
Where could I find this sample project???
In the description
Awesome video. Heap Thanks. How can I access the code for this project so that I can test it locally to play with it? Can you share the code please ?
In the description
Where is the link for the source code for this?
Description
Excellent video!
Thank you very much!
I don't know why microsoft want to go for a way different of the other languages with a specific way to run docker container. I really don't understand why this is a better solution than a docker-compose file...
Well you can technically also docker-compose for tests - but you'd have to run it manually before running the tests. Also you have to set up the connection strings yourself, etc.
Thanks Milan, its great!
Can you enable RUclips IA audio translation?
That's all handled by YT
Happy new year!
But audio track ?
What's with the audio track?
While testcontainer tests can be useful, you can continue mocking your database (the secondary adapter). Testcontainer tests still are too slow compared to tests inmmemory.
Too slow? They still complete in milliseconds