feat: Throw if container not running#1550
Merged
HofmeisterAn merged 3 commits intodevelopfrom Oct 15, 2025
Merged
Conversation
✅ Deploy Preview for testcontainers-dotnet ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
Thanks for taking the time to address this issue, Andre! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR introduces wait strategy modes. Wait strategy modes define how Testcontainers for .NET handles wait strategies. Normally, a wait strategy indicates when a container (and the service inside it) is ready to use. These strategies assume the container stays running.
However, sometimes a container fails to start and exits during startup. In those cases, Testcontainers kept retrying the wait strategy indefinitely, never indicating readiness. From a developer's point of view, it looks like the container startup is just hanging.
This PR updates the internal behavior of wait strategies. They now expect the container to be running. If the container exits unexpectedly, Testcontainers for .NET will collect the exit code and logs, then throw a meaningful exception:
ContainerNotRunningException, which includes that information.Some scenarios do not require the container to stay running. For example, running database migrations in a sidecar container during startup. In those cases, it is fine if the container exits after finishing its work. To support this, Testcontainers for .NET now provides wait strategy modes.
If you do not want an exception when a container exits unexpectedly, set the wait strategy mode to
OneShot.TODOs
Why is it important?
-
Related issues