Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace WireMock.Net.Tests.Testcontainers;

public partial class TestcontainersTests(ITestOutputHelper testOutputHelper)
public class TestcontainersTests(ITestOutputHelper testOutputHelper)
{
[Fact]
public async Task WireMockContainer_Build_And_StartAsync_and_StopAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
using WireMock.Net.Testcontainers;
using WireMock.Util;
using Xunit;
using Xunit.Abstractions;

namespace WireMock.Net.Tests.Testcontainers;

public partial class TestcontainersTests
[Collection("Grpc")]
public class TestcontainersTestsGrpc(ITestOutputHelper testOutputHelper)
{
[Fact]
public async Task WireMockContainer_Build_Grpc_TestPortsAndUrls1()
Expand Down Expand Up @@ -169,6 +171,28 @@ public async Task WireMockContainer_Build_Grpc_ProtoDefinitionAtServerLevel_Usin
await StopAsync(wireMockContainer);
}

private async Task StopAsync(WireMockContainer wireMockContainer)
{
try
{
await wireMockContainer.StopAsync();
}
catch (Exception ex)
{
// Sometimes we get this exception, so for now ignore it.
/*
Failed WireMock.Net.Tests.Testcontainers.TestcontainersTests.WireMockContainer_Build_WithImageAsText_And_StartAsync_and_StopAsync [9 s]
Error Message:
System.NullReferenceException : Object reference not set to an instance of an object.
Stack Trace:
at DotNet.Testcontainers.Containers.DockerContainer.UnsafeStopAsync(CancellationToken ct) in /_/src/Testcontainers/Containers/DockerContainer.cs:line 567
at DotNet.Testcontainers.Containers.DockerContainer.StopAsync(CancellationToken ct) in /_/src/Testcontainers/Containers/DockerContainer.cs:line 319
*/

testOutputHelper.WriteLine($"Exception during StopAsync: {ex}");
}
}

private static async Task<WireMockContainer> Given_WireMockContainerIsStartedForHttpAndGrpcAsync()
{
var port = PortUtils.FindFreeTcpPort();
Expand Down
Loading