Skip to content

Fix TestcontainersTests to ignore exception when stopping#1314

Merged
StefH merged 1 commit into
masterfrom
fix-tc-tests
Jun 11, 2025
Merged

Fix TestcontainersTests to ignore exception when stopping#1314
StefH merged 1 commit into
masterfrom
fix-tc-tests

Conversation

@StefH

@StefH StefH commented Jun 11, 2025

Copy link
Copy Markdown
Collaborator

No description provided.

@StefH StefH self-assigned this Jun 11, 2025
@StefH StefH added the test label Jun 11, 2025
@StefH
StefH requested a review from Copilot June 11, 2025 08:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

@StefH StefH mentioned this pull request Jun 11, 2025
6 tasks
@codecov

codecov Bot commented Jun 11, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.44%. Comparing base (ac9c51e) to head (9dc17a7).
Report is 2 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@StefH
StefH merged commit ec248a9 into master Jun 11, 2025
10 of 11 checks passed
@StefH
StefH deleted the fix-tc-tests branch June 11, 2025 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants