Configuration of Testcontainer, WebApplicationFactory and ConfigurationSource in ASP.NET Core.
Hi, I'm trying to figure out a nice approach to setup my tests. I am writing an application where I am using the the Options pattern in my
Program.cs
to setup some connections option:
where for instance:
In my tests where I am using WebApplicationFactory
together with Testcontainers I want to improve my setup. Can you offer me any advice on how to improve my setup code (next message).3 Replies
This is my setup:
And an example of my Testcontainer class:
Honestly, that looks pretty good to me - or at least it's similar to what I've done before when writing similar integration tests
there is a lot of boilerplate but I think it just comes with the territory unfortunately.
were you encountering any particular pain points?
Not anything particularly annoying but just always thinking about improving my code. For instance, as you said, it becomes a bit boilerplate to add new containers and I don't like having to type strings into a dictionary. But nothing is terrible or a pain point just looking for feedback 😄 Thanks for your response ❤️