Fix TestcontainersTests to ignore exception when stopping#1314
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR addresses fixing the test container teardown by separating the start and stop methods and explicitly logging any exceptions thrown during container stopping. Key changes include introducing an ITestOutputHelper parameter in the partial test class constructor, splitting the combined StartTestAndStopAsync method into StartTestAsync and StopAsync, and updating all test methods (including GRPC variants) to use these new methods.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/WireMock.Net.Tests/Testcontainers/TestcontainersTests.cs | Updated class constructor, separated container lifecycle methods, and added exception logging via testOutputHelper. |
| test/WireMock.Net.Tests/Testcontainers/TestcontainersTests.Grpc.cs | Modified GRPC tests to call the new StopAsync method instead of directly calling StopAsync on the container. |
Comments suppressed due to low confidence (3)
test/WireMock.Net.Tests/Testcontainers/TestcontainersTests.cs:18
- Introducing the ITestOutputHelper parameter in the partial class may require ensuring that all partial definitions are updated to use a consistent constructor. Please verify that the instantiation of this partial class remains correct across the test suite.
public partial class TestcontainersTests(ITestOutputHelper testOutputHelper)
test/WireMock.Net.Tests/Testcontainers/TestcontainersTests.cs:129
- [nitpick] Consider renaming StopAsync to StopContainerAsync for improved clarity on its purpose within the test lifecycle. This naming can help differentiate it from any potential StopAsync methods on the container itself.
private async Task StopAsync(WireMockContainer wireMockContainer)
test/WireMock.Net.Tests/Testcontainers/TestcontainersTests.Grpc.cs:72
- Ensure that calling StopAsync from the GRPC tests correctly references the instance method defined in the partial class. Consistency in lifecycle management across test cases is important to prevent unexpected behaviors.
await StopAsync(wireMockContainer);
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1314 +/- ##
==========================================
- Coverage 36.45% 36.44% -0.02%
==========================================
Files 175 175
Lines 39214 39214
==========================================
- Hits 14297 14290 -7
- Misses 24451 24456 +5
- Partials 466 468 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.