WireMock-Net / WireMock.Net

WireMock.Net is a flexible product for stubbing and mocking web HTTP responses using advanced request matching and response templating. Based on the functionality from http://WireMock.org, but extended with more functionality.
Apache License 2.0
1.35k stars 197 forks source link

WireMock.Net 1.5.46 is incompatible with TestContainers 3.7.0 (issue 2) #1059

Closed ruairica closed 5 months ago

ruairica commented 5 months ago

Describe the bug

When using another TestContainers Module that relies on Testcontainers 3.7.0, WireMock container throws an exception. Program.cs

using DotNet.Testcontainers.Builders;
using WireMock.Net.Testcontainers;
await new WireMockContainerBuilder()
    .WithAutoRemove(true)
    .WithCleanUp(true)
    .Build().StartAsync().ConfigureAwait(false);

await new ContainerBuilder()
    .WithImage("testcontainers/helloworld:1.1.0")
    .WithPortBinding(8080, true)
    .WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(r => r.ForPort(8080)))
    .Build()
    .StartAsync()
    .ConfigureAwait(false);

this code fails throws exception

Unhandled exception. System.MissingMethodException: Method not found: 'Void DotNet.Testcontainers.Configurations.ContainerConfiguration..ctor(DotNet.Testcontainers.Images.IImage, System.Func`2<Dock
   at WireMock.Net.Testcontainers.WireMockConfiguration..ctor(String username, String password)
   at WireMock.Net.Testcontainers.WireMockContainerBuilder..ctor()

when the csproj is

    <PackageReference Include="WireMock.Net.Testcontainers" Version="1.5.46" />
    <PackageReference Include="Testcontainers.CosmosDb" Version="3.7.0" />

the exception is not thrown when I downgrade Testcontainers.CosmosDb to 3.6.0.

Expected behavior:

On nuget (https://www.nuget.org/packages/WireMock.Net.Testcontainers#dependencies-body-tab) states atleast 3.6.0 TestContainers https://www.nuget.org/packages/Testcontainers/) (>= 3.6.0) so I would expect it not to throw an exception when I upgrade the other module to 3.7.0

Test to reproduce

Create a new console application add the following to .csproj

  <PackageReference Include="WireMock.Net.Testcontainers" Version="1.5.46" />
    <PackageReference Include="Testcontainers.CosmosDb" Version="3.7.0" />

Program.cs:

using Testcontainers.CosmosDb;
using WireMock.Net.Testcontainers;

await new WireMockContainerBuilder()
    .WithAutoRemove(true)
    .WithCleanUp(true)
    .Build()
    .StartAsync();

await new CosmosDbBuilder()
    .Build()
    .StartAsync()
    .ConfigureAwait(false);
StefH commented 5 months ago

@ruairica You can try preview version 1.5.46-ci-18317 if that solves your problem.

https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions

StefH commented 5 months ago

https://github.com/WireMock-Net/WireMock.Net/issues/1059

StefH commented 5 months ago

I'll release a new official NuGet today.