Тёмный

The cleanest way to use Docker for testing in .NET 

Nick Chapsas
Подписаться 294 тыс.
Просмотров 87 тыс.
50% 1

Check out my courses: dometrain.com
Become a Patreon and get source code access: / nickchapsas
Hello everybody I'm Nick and in this video I will show you how you can quicly spin up and tear down docker containers specific to your test executions. This is only a fraction of what I show in my Integration Testing course so if you want to learn even more cool topics like this check nickchapsas.com out.
Workshops
NDC Oslo | 26 - 30 Sept | bit.ly/ndcoslo2022workshop
NDC Sydney | 10 - 14 Oct | bit.ly/ndcsydney2022workshop
dotnetdays | 20 - 22 Oct | bit.ly/dotnetdays2022workshop
NDC Minnesota | 15 - 18 Nov | bit.ly/ndcminnesota2022workshop
NDC London | 23-27 January 2023 | bit.ly/ndclondon2023
Give TestContainers a star on GitHub: github.com/testcontainers/tes...
Don't forget to comment, like and subscribe :)
Social Media:
Follow me on GitHub: bit.ly/ChapsasGitHub
Follow me on Twitter: bit.ly/ChapsasTwitter
Connect on LinkedIn: bit.ly/ChapsasLinkedIn
Keep coding merch: keepcoding.shop
#csharp #dotnet #testing

Опубликовано:

 

24 июл 2022

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 143   
@JohnOliverAtHome
@JohnOliverAtHome Год назад
That is absolutely excellent. Thanks Nick. Definitely going to share this with the rest of the team at work. Another clean and clear video.
@shadowsir
@shadowsir Год назад
Heh, what a coincidence. I just discovered TestContainers a week ago and started using it in our integration tests. It's pretty darn awesome. Great content as usual, Nick!
@vekzdran
@vekzdran Год назад
This is gold. Really. No more need to complicate with multiple DB services in CICD or docker-compose just to bring up databases. Thanks!
@austinejei
@austinejei Год назад
Amazing introduction. Thanks Nick!!
@tplummer217
@tplummer217 Год назад
Nick is great at showing us hidden gems like this. Great work!
@pedrormiguel125
@pedrormiguel125 Год назад
Excellent content, thanks for sharing to us.
@guilla5
@guilla5 Год назад
Thanks for helping so much with this video in simplifying testing in my job, this seems like a great approach!
@dandoescode
@dandoescode Год назад
Great video Nick! For our integration tests we need a good amount of static and transactional data setup. We settled on a similar strategy to yourself where we clean DB's per test collection. However, we still found creating new DB's too slow, so we instead settled on using Respawn to intelligently clear transactional data while leaving static data intact. This has worked great for us. One disadvantage though, is that we can't parallelise the tests as you've shown.
@nickchapsas
@nickchapsas Год назад
Respawn is getting a video next month. it’s pretty cool
@prouleau4440
@prouleau4440 Год назад
I will have to test Respawn. I created my own solution. It uses database snapshots and the database is "seeded" from a .SQL script file. The first test create the database and make the snapshot; other tests revert back to the snapshot before running.
@mohammadazhdari4469
@mohammadazhdari4469 Год назад
Why not just create a local image with static data already there, and run containers based on that image? I haven't tested this though
@nickchapsas
@nickchapsas Год назад
@@mohammadazhdari4469 It's a perfectly fine solution it just needs a bit more handholding because you have to keep it up do date
@igelineau
@igelineau Год назад
I have just finished implementing a similar approach, but to handle parallelism, we are using 1 db container instance per test assembly, then 1 Sql database per testFixture. We then override the connection string in the OneTimeSetUp of each TestFixture. It allows parallelism at the class level while avoiding too much RAM usage. ultimately I'll want to use only 1 container for all the assemblies, but it requires inter-process synchronization (Mutex) for making sure we create the container only once. We have also appended part of the hash from the list of migrations to the name of the container, so whenever the list of migrations is modified, a new container is bootstrapped. Another thing I noticed is it's best to leave the container running between runs (at least during local development), because otherwise it takes at least ~5 seconds to start on each run. One thing I found lacking with the TestContainers is the lack of support for already-running containers. Because of that, we had to implement some of the code manually and use a wrapper class to handle both cases. This issue explains the problem: github.com/testcontainers/testcontainers-dotnet/issues/506
@DeadDad1
@DeadDad1 Год назад
Excellent, excellent video thank you very much Nick!
@IamSystemko
@IamSystemko Год назад
Hi Nick! We have been using TestContainers in our team for six month. Awesome library to facilitate and standardize using of docker containers in NET. The same running procedure for integration tests from both IDE and CI/CD cannot be overstated:) Also I want to mention that we are not using "one class - one container" approcah, because most of the time muiltiple tests should rely on the same data in database. We ended up with custom abstactions for container and dbcontext that give us ability to create one or several databeses per any scope of tests. We have separate nuget packages for EF6 and EFCore due to different approach for configuring and providing DbContext instances in integration tests. Code base is super small but very useful.
@florianvandillen
@florianvandillen Год назад
Do you use the containers inside a CI/CD pipeline such as Azure DevOps? If so, how?
@davidmata3104
@davidmata3104 Год назад
It would be good if you can write a post about how you do it ( custom abstactions for container and dbcontext that give us ability to create one or several databeses per any scope of tests)
@moranmono
@moranmono Год назад
This is a brilliant video. Thank for the info
@CleverWheels
@CleverWheels 4 месяца назад
Super slick! Love it, thank you.
@stefanbogdanovic590
@stefanbogdanovic590 Год назад
Amazing content Nick! Thank you!
@jmorsali
@jmorsali Год назад
I realy real exited to use this superb library. It is exactly things that I wanted.
@geekrs1987
@geekrs1987 Год назад
Awesome content! Thank you for sharing 👍
@andreiclaudiu507
@andreiclaudiu507 Год назад
Hey! I've been using Fluent Docker(or Ductus for some) for running integration tests inside a Docker container for over a year now and it has been great so far. I didn't even know there are any alternatives to it before I stumbled upon on your video. However, after watching your video, I would love if you could do a small parallel between the two of them as I am sure there are some differences or other things that one does better over the other. Great video again and can't wait to see you in Romania!
@kevinross7165
@kevinross7165 Год назад
Every time I watch one of your videos it reminds me of how much of a cowboy developer I am! 😀 I really should sign up for some of your courses.
@vitalizinevich1231
@vitalizinevich1231 Год назад
Thank you! looks really convinient and easy!
@ezecel9
@ezecel9 Год назад
Amazing video, thanks
@TimitrixArtZ
@TimitrixArtZ Год назад
I use this package for a long time and it saves me a lot of effort configuring containers for testing different pars of my systems. Here is a small helper method to get the next free port with a significantly lower risk to choose an already used port : public static int GetNextPort() { // Let the OS assign the next available port. Unless we cycle through all ports // on a test run, the OS will always increment the port number when making these calls. // This prevents races in parallel test runs where a test is already bound to // a given port, and a new test is able to bind to the same port due to port // reuse being enabled by default by the OS. using var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Bind(new IPEndPoint(IPAddress.Loopback, 0)); return ((IPEndPoint)socket.LocalEndPoint!).Port; }
@igelineau
@igelineau Год назад
you don't need custom code, you can use this overload (on the TestcontainersBuilder) and it'll choose a random port for you: .WithPortBinding(1433, assignRandomHostPort: true)
@thespicycoder5583
@thespicycoder5583 Год назад
This looks similar to FluentDocker, that you presented in one of your videos "5 open source .NET projects that deserve more attention" Very useful, Thank you
@khryomakhina
@khryomakhina 8 месяцев назад
Semantic test case naming convention. A good one 👍
@bramburn
@bramburn Год назад
thanks nick this helped.
@julienlefevre1661
@julienlefevre1661 Год назад
Would be nice to have a video on the latest version of Testcontainers as it makes this video obsolete :) Thanks for your great work
@poteb
@poteb Год назад
Nick, I have a request for your videos, please turn on tracking of the selected file in the solution explorer pane. This would help to better keep track of the selected file when you sometimes go a bit fast between file. Love your content. See you at NDC Oslo!
@ali_randomNumberHere
@ali_randomNumberHere Год назад
great video, please make more content about docker.❤️
@rpchost
@rpchost Год назад
Great video Nick as always, one question please, how did you run the initial migration scripts, I see there is DatabaseInitializer but I can't see where you used it
@Nazaro4ka
@Nazaro4ka 9 месяцев назад
thanks for the video
@seldomseen_78
@seldomseen_78 Год назад
Great stuff as always. Quick question - How did you create the table in the database?
@marcellorenz2963
@marcellorenz2963 Год назад
Assuming you're using EF Core and not Linq2Db, for example, you can use the DbContext to get the migrations and migrate if any migration is pending. Otherwise you can call EnsureCreated which will only work on a fresh database with no tables.
@jrobertoaraujo
@jrobertoaraujo Год назад
This was a brilliant video where you could present a great tool to improve productivity on programming and running integration tests, every developer suffer when setting up test env to do that. I would like to leave a suggesting: this kind of test is built in the way where might increase the consumption of resources, instantiating new containers every time a new test method is run. Wouldn’t it be more performant if the customerApiFactory class was instantiated once, and then when all customer’s tests was done, the factory class was killed?! Yes, I know that, in this case, the test implementation should implement some kind of cleanup cleanup! Wouldn’t have another approach to consume less resources?
@azatkalimullin3136
@azatkalimullin3136 Год назад
Hi Nick, thanks for your video. What do you do with db mirgations when using Testcontainers? Are they executed every time the test suite is run, or is there a way to reuse a container with migrations applied once?
@nickchapsas
@nickchapsas Год назад
It depends on your execution model and whether you wanna run all the tests in parallel or in sequence
@JustinAdler
@JustinAdler Год назад
Great video Nick. Don't forget peeps .. RavenDb is another awesome (and so underrated) Document DB which could also be used here. Nice :)
@nickchapsas
@nickchapsas Год назад
There are probably 4-5 alternatives that I’d use before I even considered RavenDb for any real world application
@JustinAdler
@JustinAdler Год назад
@@nickchapsas Eeks - that's pretty .. damning :(
@ConnorZ
@ConnorZ Год назад
@@nickchapsas Hey Nick. Clearly you are an advocate for C# (me too). I have yet to see a database client that comes even close to RavenDB's C# integration. My words truly cannot give enough justice to RavenDB. As a fellow C# developer, I highly recommend you to give it another try.
@ConnorZ
@ConnorZ Год назад
Not to mention the fact that I successfully launched a video game in production using RavenDB. Had no problems handling 17k+ concurrent users. I picked RavenDB for a good reason. The C# integration was above and beyond. Try the MongoDB client for 10 minutes and you will see how terrible it is.
@olibanjoli
@olibanjoli Год назад
@@nickchapsas could you name those alternatives? have you tried ravendb yet?
@mfregonassi
@mfregonassi Год назад
A nice way to use TestContainers in integration testing is in conjunction with xUnit collection fixtures.
@RajaKajiev
@RajaKajiev Год назад
Can you say a bit on why it is so? What makes use of xUnit "nice"? :-?
@PeriMCS
@PeriMCS Год назад
@@RajaKajiev not XUnit, but Xunit Collections
@RajaKajiev
@RajaKajiev Год назад
@@PeriMCS ok, meditate on this I will (c) Yoda
@bramburn
@bramburn Год назад
I like this, interesting
@davidmataviejo3313
@davidmataviejo3313 Год назад
Great video Nick. How would you do it if some tests do need to run sequentially and need the information from the results from other tests?
@riteshkumar433
@riteshkumar433 7 месяцев назад
Standard practice is to keep tests independent of each other
@zblocker
@zblocker Год назад
Great content as always Nick. As recently as September 2021, you highlighted FluentDocker for this same niche (that of integration test Docker orchestrators). Do you now favor TestContainers over FluentDocker, or do you see a use for both of them?
@nickchapsas
@nickchapsas Год назад
It depends on the usecase. I use both and in my integration testing course I show both usecases
@jakobstengard3672
@jakobstengard3672 Год назад
So i have tried this approach before. The problem i have with it is that you end up running several database instances on you local machine which can get slow when the number of tests increases. Postgres has a habbit of restarting itself one time before it comes online if you mount scripts to add extensions like plv8, which means you need to wait 10 seconds before you can run the tests. Its also problematic if you are dependent on other services which need to built from dockerfiles in the same project. Maybe you need to for example run dbmigrations before you can run the tests. The nice thing with docker compose is that it will fire up all your services, you message queue, you amazon stack, you databases, your apis, everything with one command and then you can just run your tests. Of course, some of them cannot run in paralel. But often you can work around it by for example testing different scenarios on different users or different accounts. So even if each scenario is sequential you can run several scenarios in paralell.
@talp0sh
@talp0sh Год назад
Great video, thanks! As I understand you generate your database schema from C# code. What would I need to do if my database schema was generated by a set of SQL commands or some external tool? Is it possible to apply "external" database migration?
@nickchapsas
@nickchapsas Год назад
Sure thing, you can either bake that on the docker startup level. Simply call the scripts towards the database your gonna run the tests against. You might wanna look at a library called Respawn to allow you to get back to a given state for every test
@zokocx
@zokocx Год назад
Nice video and thanks for introducing this nuget package to us. But in version 3.x.x code for setting TestContainers has little changed now there are separated nuget packages base on what you want to have in container. For example in video Testcontainers.PostgreSql need to be installed not just Testcontainers.
@T___Brown
@T___Brown Год назад
This makes me want to write an integration test. Thanks
@namkbarsidil249
@namkbarsidil249 Год назад
Hello Nick, very nice video, thanks! One question though, since it is creating a database container for every test, it could get out of hand easily when you have lots of tests. Is there an option to counter this?
@nickchapsas
@nickchapsas Год назад
In this example it doesn’t create a new database for each test but rather one database for each test set which in this case it is a class. If you group your tests logically and do minimal clean up, you can run less databases like I show in the example. You can also run one and clean up after every test assuming you configured the tests to run one after the other. You control this fully and it is a balance between how much you wanna cleanup and how much you can parallelise
@namkbarsidil249
@namkbarsidil249 Год назад
@@nickchapsas Yea, sorry, it is creating one database for each test set, not for every test, my bad but still it can be a lot when you have more and complicated tests. So, is there any option in the package to differentiate and control the created containers? For example, putting an attribute to use a naming instance ([ContainerName="Container1"] for example) over the tests to use an existing one or create a new one. Or should we do this manually?
@namkbarsidil249
@namkbarsidil249 Год назад
To answer my own question, after couple of experiments, I think best way is to handle multiple setups and prevent creating new databases for every setup is to use the solution @Daniel Mackay gave (using Respawn).
@akimbbo_upnext
@akimbbo_upnext Год назад
Great video! But i got somewhat related question. Whole weekend i was trying to implement transactions for my integration tests which are using in memory client provided by WebApplicationFactory. I tried to wrap my test code in TransactionScope but nothing work. I also tried to re-register my dbcontext as singleton for my integration tests webapi instance so i could retrieve transaction and rollback it but it also wasnt a solution. I ended up deleting and recreating db after each integration test. Do you guys have any snippet that implements transactions for integrity testing using WebApplicationFactory?
@Anymn1
@Anymn1 Год назад
Nice video, but can you use timestamps next time? It's a very handy feature that helps people finding the parts they do know / didn't know yet, saving valueable time
@khavea
@khavea Год назад
Thanks for the yet another great video. Is there a way we can run these in the devops pipelines? What are the pre-req for the same?
@nickchapsas
@nickchapsas Год назад
The pipeline needs to support Docker but that's it. I've used it with TeamCity without any problem
@PinoyDIY
@PinoyDIY Год назад
I'm working on existing application which uses lots of stored procedures and few more tables. I was able to automate the recreation of these sql objects upon starting of integration tests using EF migration that fires this sql scripts on `Migrate`. If I do this for each invidiual tests, this might add a lot of time provisioning each instance of docker db server instead of re-using the same instance and just do a cleanup for each test. The side effect on our approach as you mentioned is we can't run it on parallel unless we guaranteed our test data like GUID idenfier id test data. Even with this approach, our integration test completion time is still fast. I might do some comparison between these approach running on parallel and see performance gain. Also not sure how much cpu and memory utilization we gonna consume on the CI pipeline, let says if we spawn 10 instance or whatever the parallel number the test is running.
@MrDaedra88
@MrDaedra88 Год назад
You could use .EnsureCreated() instead of applying migrations. It's way faster
@kevindammann6014
@kevindammann6014 Год назад
One question which came in my mind regarding those containers is: What if I want to have the testdatabase created by an ef core migrator?
@davidmata3104
@davidmata3104 Год назад
How do you create the database and all the tables? Do we run all migrations in our project?
@martinhoge
@martinhoge Год назад
I maybe overheard it, but how do you approach db deployment to your database in test container? we use Database project in our company and that'd need to be deployed first there.
@harisuru
@harisuru Год назад
Hi Nick, we do have similar problem, however we are using UI testing and cant run the tests in parallel. Any solution for these scenario, great if you could do a video on running UI testing parallel.
@MooseVonStanley
@MooseVonStanley Год назад
We currently use docker compose for our tests to fire up a mysql instance and then create a new db for each suite of tests. I could be missing it, but I would think creating one container with multiple DBs will be more performant than bringing up/down containers?
@nickchapsas
@nickchapsas Год назад
You won't really see a difference because of how memory is allocated on containers. It is the database itself which is the slow part, not the spinup of containers
@MrRclemens
@MrRclemens Год назад
Great video! Could this be combined with entity framework? We have a code first setup and this would be great if the docker database could always be the same as the real database
@nickchapsas
@nickchapsas Год назад
Sure it can
@user-ex5km9kj9h
@user-ex5km9kj9h 10 месяцев назад
Yo, if you have some test objects where you make tests with, how do you manage when you try to insert same object or when you already inserted an object and run the test again?
@shomari169
@shomari169 Год назад
Great tutorial as always, i just wanted to ask if all these scenario are part of your current courses; if no then will it be updated with these new features?
@nickchapsas
@nickchapsas Год назад
Yes my integration testing course covers this in way more detail and it shown another way to do this for applications with a front end
@shomari169
@shomari169 Год назад
@@nickchapsas now i just need to save to get the bundle course
@pianochess1882
@pianochess1882 Год назад
Interesting! How did you run the initial migration scripts (ie creating the customer table)?
@MindlessTurtle
@MindlessTurtle Год назад
I'm guessing it's somewhere in the DatabaseInitializer.cs file in the Database folder of the project.
@ramymawal8295
@ramymawal8295 Год назад
You can also have it be in the ConfigureServices in the webhost builder in the WebApplicationFactory class
@alessandrovangeli8395
@alessandrovangeli8395 Год назад
Great! How can you start a db already populated?
@pdevito
@pdevito Год назад
Yup, this is pretty much what we do only we use NUnit to set up one db for everything. Having a db per class would be… a lot of db’s 🙃
@drewfyre7693
@drewfyre7693 Год назад
Great content. You forgot the link to the nuget package in the description.
@nickchapsas
@nickchapsas Год назад
Sorry for that, it’s there now
@meirkr
@meirkr Год назад
Great content. How can such test suite be running in a CI/CD? Is there ability to deploy the tests as docker image and run it via cmd line without having dotnet test runner environment?
@nickchapsas
@nickchapsas Год назад
Absolutely. I’ve been running this in my CI pipeline in TeamCity
@otetsdiodor
@otetsdiodor Год назад
Thx a lot, I briefly look through Azure DevOps docs and I can't realize is this approach could be used with AzureDevOps
@mryildiz702
@mryildiz702 Год назад
If your Agent has docker up and running, it will run it without problem on Azure Devops.
@David-rz4vc
@David-rz4vc Год назад
Was watching a vid by Jason Taylor where he used respawn library that intelligently wipe your tables after Ur test finish running but this means u need to have two database active at time. Guess his way and ur way both works
@nickchapsas
@nickchapsas Год назад
Respawn is great for this I’m planning to make a dedicated video on the library
@norbertcsibi7720
@norbertcsibi7720 4 месяца назад
Can you do something like having a test run an having to build the config (app settings) every time we run a test?
@softcadbury
@softcadbury Год назад
Nice video, thanks ! The only problem I see with this package is that you can't run the tests themselves in docker right ?
@blitzkringe
@blitzkringe Год назад
If you need to control docker from inside of a docker container, you can bind mount docker control socket into the container.
@bedhiafighassen7788
@bedhiafighassen7788 4 месяца назад
Can we run tests with azure devops pipelines ?
@N0151
@N0151 Год назад
I tried reproduce the steps and an exception was thrown (Testcontainer has not been created), the database used is MySql 8 I noticed the method InitializeAsync of IAsyncLifetime isn't being reached, is there some chance of the issue being related at MySqlTestcontainer?
@florianvandillen
@florianvandillen Год назад
Hey Nick, how would you run these tests in CI/CD such as Azure Devops pipelines? Is it possible to use the cloud build agent as a Docker host?
@nickchapsas
@nickchapsas Год назад
I've been using TeamCity for that, and in TeamCity it is possible to have docker running in the agent yes
@zsolter14
@zsolter14 Год назад
@@nickchapsas Are you running the tests in the host? We have a problem where we run the tests while building the docker image (so in docker build there is a command that runs the tests) which makes it really hard to use this tool. Have you faced the same problem?
@MaxHogan80
@MaxHogan80 Год назад
Instead of running a new container each time you need to execute an integration test (or a set), what about using the same container e and creating/deleting a new db instance with a different guid name?
@nickchapsas
@nickchapsas Год назад
The container itself isn't the "heavy" thing. Its the data that you gonna need to seed into it that might take time. DB Instances are effectively as cheap as containers or at least you wouldn't see a visible difference.
@anlKaynarr
@anlKaynarr Год назад
Testcontainers is cool.
@yossiyaari3760
@yossiyaari3760 Год назад
Very cool tooling. A) where does the schema load? And how does that affect test time? B) in Java we can specify to keep the container live after the test is complete. Is there an option like that? C) in Java the default flow uses transactions to keep the DB "clean" between tests. Is that an option here?
@nickchapsas
@nickchapsas Год назад
A) in this case migrations run on startup and create the schema. They are usually very fast. If you have a very lenghty migration time, simply create a docker image with the schema and all the data pre-seeded and use that for testing. B) Yes, if you don't dispose the container in the dispose method it will stay up C) In C# there are multiple ways to interface with the DB so you control the transaction scope yourself. This example shows how you can create a clean DB every time so you don't have to worry about cleaning data.
@igelineau
@igelineau Год назад
B) .WithCleanup(false)
@rafaelmelo6236
@rafaelmelo6236 Год назад
How about the performance? Isn't it too heavy to instantiate multiple postgres dockers for each unit test.
@nickchapsas
@nickchapsas Год назад
These are not unit tests, these are integration tests. It depends on the metal you are running on but with the ram we have today, you can run a lot of them before you have any problem especially with them being created and deleted as the tests are running
@adem_sahin_
@adem_sahin_ Год назад
What if I have lots of migrations to run to create a new db? Is it still a good way to go?
@nickchapsas
@nickchapsas Год назад
Sure thing. You can deal with it in multiple ways from a docker image that has them already run, to backup restore on startup to using a library like Respawn to go back to a snapshot
@carlosamaya8607
@carlosamaya8607 Год назад
how could I run this in a azure pipeline that uses service frabric? it is possible....this is a great tool I'd like to bring to my team
@daneel_olivaw
@daneel_olivaw Год назад
How does this compare to Respawn, is it faster or slower? With Respawn you can't have parallelism but you're not creating/destroying DB for each test. This looks awesome but it seems like it would be resource-intensive and slow since it has to create DB, apply migrations, run a test, then destroy DB - all this for each test.
@nickchapsas
@nickchapsas Год назад
It's not for each test. It's for each test collection
@MrXzxzxc
@MrXzxzxc Год назад
I assume your WEB API creates a DB schema. If so, how do you synchronize it in a microservice production environment?
@nickchapsas
@nickchapsas Год назад
You can run your migrations and seed data on startup or have a docker image with all the schema and data pre-seeded
@MrXzxzxc
@MrXzxzxc Год назад
@@nickchapsas thank you for the answer! I very much appreciate that. We tried migrating DB in a microservice itself, but when we scaled it to multiple instances, we had to lock migration somehow. And this adds unnecessary complexity. Also, we tried creating custom images, but this didn't work too. Because a script that creates schema starts at the same time as a DB server, so you can't wait for an open port, you should wait for the last migration applied, which is hard to determine. I'll research this lib, maybe it can help with my problem.
@fakhrulhilal
@fakhrulhilal 6 месяцев назад
That's the problem with XUnit, there is no concept for test session setup like NUnit has. XUnit closest similar feature is collection fixture which defined by code statically.
@mahmoudalaskalany
@mahmoudalaskalany Год назад
Awesome one Can you please attach the github repo code sample to use it
@nickchapsas
@nickchapsas Год назад
The code is available to my patreons
@Tolmachovtv
@Tolmachovtv 4 месяца назад
What happened to the tests approach - seeds test data (arrange) - performs a test scenario (act) - checks the data (assert) - deletes test data used in this scenario after execution (teardown, clean up) ? When test data not spreaded in multiple scenarios - everything works fine. Each test works with it's own test data. Or I missed something?
@Tolmachovtv
@Tolmachovtv 4 месяца назад
I think I got the idea - with this approach you don't need to think about managing test data in DB at all
@sps014
@sps014 Год назад
Kubernetes tutorial please
@carlitoz450
@carlitoz450 Год назад
By curiosity : why don't you just replace service instead of remove and add ?
@nickchapsas
@nickchapsas Год назад
Removing based on typeof will remove all the implementations. You'll usually just have one but there are cases where you might have more than one
@carlitoz450
@carlitoz450 Год назад
btw nice video. lookin forward to swtich from SQLite inmemory to this and give it a try .
@IldarIsm
@IldarIsm Год назад
Hi, Nobody asks how much RAM these tests consume and if the container go down, i suppose the test will fail.
@nickchapsas
@nickchapsas Год назад
The container won't go down unless the test executes and the RAM is relative to your docker configuraiton
@devopsbrain
@devopsbrain Год назад
And now we need to talk about memory for 10000 tests =)
@idan5323
@idan5323 Год назад
Hey Nick, the random ports looks like a really bad practice. It can be a reason for flaky tests, which are unreliable and can mask real problems I think that writing custom port error handling might be the only solution
@nickchapsas
@nickchapsas Год назад
Which random ports? The ones that the library picks of you automatically? Those internally are checked for availability so it will never pick ports that are not available.
@idan5323
@idan5323 Год назад
@@nickchapsas Ok then, thats cool.. nice video, thanks
@user-ti7zu7wz5e
@user-ti7zu7wz5e 3 месяца назад
Seems like the video content is outdated because of test containers updates
@thegenxgamerguy6562
@thegenxgamerguy6562 Год назад
Or save yourself a lot of headache and get rid of all this 1970s "SQL" nonsense. No-SQL databases are far superior and much more easy to integration test against.
@zokocx
@zokocx Год назад
You clearly not now why RDBMS are used and when to go to NoSQL. For you it's just SQL and NoSQL.
@oxidoa4833
@oxidoa4833 Год назад
Who you are teaching Docker with vscode?? Be serious pls
@elpe21
@elpe21 Год назад
Be serious, where do you see vscode in the video?
@fynnschapdick4434
@fynnschapdick4434 Год назад
First of all , he didnt teach docker at all. He presented a nuget package called "TestContainers" to simplify your integration tests. Second, there is no vscode, its called "Rider" from jetbrains. Finally one question, what is your point? Using vscode is not bad habbit. Use the IDEl, you feel comfortable with.
Далее
What is Span in C# and why you should be using it
15:15
When To Unit, E2E, And Integration Test
14:58
Просмотров 89 тыс.
The CORRECT way to implement Retries in .NET
17:01
Просмотров 86 тыс.
"I Lost a Job Because of This Codebase"
14:08
Просмотров 59 тыс.
Testcontainers - From Zero to Hero. By @MarcoCodes
1:01:29
The New .NET 9 HybridCache That You Must Upgrade To!
14:34
You are mocking the HttpClient the wrong way
13:56
Просмотров 48 тыс.
Don't throw exceptions in C#. Do this instead
18:13
Просмотров 251 тыс.
Why Developers Hate "Clean Code"?
14:39
Просмотров 56 тыс.