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 1) #1054

Closed lukasszh closed 5 months ago

lukasszh commented 5 months ago

Describe the bug

After upgrading from .NET 7 to version 8, WireMock cannot be started anymore.

Test to reproduce

Once this line is added to the IClassFixture of xUnit, the error message appears.

private readonly WireMockContainer _wireMockContainer = new WireMockContainerBuilder().WithAutoRemove(true).Build();

With .NET 7 and the same setup, everything worked perfectly fine.

Stacktrace

System.AggregateException
One or more errors occurred. (Method not found: 'Void DotNet.Testcontainers.Configurations.ContainerConfiguration..ctor(DotNet.Testcontainers.Images.IImage, System.Func`2<Docker.DotNet.Models.ImageInspectResponse,Boolean>, System.String, System.String, System.String, System.String, System.Collections.Generic.IEnumerable`1<System.String>, System.Collections.Generic.IEnumerable`1<System.String>, System.Collections.Generic.IReadOnlyDictionary`2<System.String,System.String>, System.Collections.Generic.IReadOnlyDictionary`2<System.String,System.String>, System.Collections.Generic.IReadOnlyDictionary`2<System.String,System.String>, System.Collections.Generic.IReadOnlyDictionary`2<System.String,DotNet.Testcontainers.Configurations.IResourceMapping>, System.Collections.Generic.IEnumerable`1<DotNet.Testcontainers.Containers.IContainer>, System.Collections.Generic.IEnumerable`1<DotNet.Testcontainers.Configurations.IMount>, System.Collections.Generic.IEnumerable`1<DotNet.Testcontainers.Networks.INetwork>, System.Collections.Generic.IEnumerable`1<System.String>, System.Collections.Generic.IEnumerable`1<System.String>, DotNet.Testcontainers.Configurations.IOutputConsumer, System.Collections.Generic.IEnumerable`1<DotNet.Testcontainers.Configurations.IWaitUntil>, System.Func`3<DotNet.Testcontainers.Containers.IContainer,System.Threading.CancellationToken,System.Threading.Tasks.Task>, System.Nullable`1<Boolean>, System.Nullable`1<Boolean>)'.) (The following constructor parameters did not have matching fixture data: TestFactory factory)
  Exception doesn't have a stacktrace

System.MissingMethodException
Method not found: 'Void DotNet.Testcontainers.Configurations.ContainerConfiguration..ctor(DotNet.Testcontainers.Images.IImage, System.Func`2<Docker.DotNet.Models.ImageInspectResponse,Boolean>, System.String, System.String, System.String, System.String, System.Collections.Generic.IEnumerable`1<System.String>, System.Collections.Generic.IEnumerable`1<System.String>, System.Collections.Generic.IReadOnlyDictionary`2<System.String,System.String>, System.Collections.Generic.IReadOnlyDictionary`2<System.String,System.String>, System.Collections.Generic.IReadOnlyDictionary`2<System.String,System.String>, System.Collections.Generic.IReadOnlyDictionary`2<System.String,DotNet.Testcontainers.Configurations.IResourceMapping>, System.Collections.Generic.IEnumerable`1<DotNet.Testcontainers.Containers.IContainer>, System.Collections.Generic.IEnumerable`1<DotNet.Testcontainers.Configurations.IMount>, System.Collections.Generic.IEnumerable`1<DotNet.Testcontainers.Networks.INetwork>, System.Collections.Generic.IEnumerable`1<System.String>, System.Collections.Generic.IEnumerable`1<System.String>, DotNet.Testcontainers.Configurations.IOutputConsumer, System.Collections.Generic.IEnumerable`1<DotNet.Testcontainers.Configurations.IWaitUntil>, System.Func`3<DotNet.Testcontainers.Containers.IContainer,System.Threading.CancellationToken,System.Threading.Tasks.Task>, System.Nullable`1<Boolean>, System.Nullable`1<Boolean>)'.
   at WireMock.Net.Testcontainers.WireMockConfiguration..ctor(String username, String password)
   at WireMock.Net.Testcontainers.WireMockContainerBuilder..ctor()
   at ../TestFactory.cs:line 22
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

Xunit.Sdk.TestClassException The following constructor parameters did not have matching fixture data: TestFactory factory Exception doesn't have a stacktrace

StefH commented 5 months ago

https://github.com/WireMock-Net/WireMock.Net/pull/1057

StefH commented 5 months ago

@lukasszh I did test it in my Windows machine using Windows and Linux Docker, and .NET6, 7 & 8 work fine.

StefH commented 5 months ago

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

StefH commented 5 months ago

@lukasszh Are you also using TestContainers version 3.7.0 ?

StefH commented 5 months ago

@lukasszh 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

lukasszh commented 5 months ago

@StefH: Thank you for the quick problem analysis!

After some further problem analysis, I found out that it is also related to the compatibility with TestContainers 3.7.0. Using your fix 1.5.46-ci-18317 has solved my problem.

StefH commented 5 months ago

Thanks for confirming.

I'll release a new official NuGet today.