How to create and manage unit test resources (best practices) #438
HofmeisterAn
started this conversation in
Show and tell
Replies: 1 comment 3 replies
-
The documentation (https://dotnet.testcontainers.org/) isn't very explanatory. What is "TestcontainersVolumeBuilder" and what it does? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'd like to share and discuss best practices and examples of how to create and manage Docker resources in unit tests with .NET Testcontainers. I see frequently questions where developers ask about common patterns. Furthermore, I noticed that some developers are not aware of the asynchronous API and the different ways to set up and cleanup fixtures in testing tools.
The example below uses xUnit.net. It creates and shares a fixture
Volume
among all unit tests. Each unit test creates a freshContainer
instance. The first unit test executes a command inside the container. The second one sends a simple HTTP request to the container.I've added comments to the important sections. This helps to understand the basic concept. .NET Testcontainers allows tests for all kinds of use cases. Let me know if you need further explanations or what best practices you are interested in?
Beta Was this translation helpful? Give feedback.
All reactions