mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 14:20:29 +01:00
WireMock server fails to respond when run from VS test process #236
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @peitschie on GitHub (Dec 18, 2019).
TL;DR: WireMock for net641 (i.e., AspNetCore) hangs when executed from some Visual Studio test runners. The solution is to upgrade to Microsoft.AspNetCore v2.1.7. This can be done simply by referencing the Microsoft.AspNetCore v2.1.7 nuget package directly in the same library/console app that is referencing the WireMock nuget package.
This isn't a WireMock bug per se, but I wanted to log it here just in case others hit this problem.
The long version:
I'm using SpecFlow with the SpecFlow extension in Visual Studio 2017 on a .NET 4.6.1 project. I found that running WireMock with Kestrel from within this the Visual Studio test runner (via Test Explorer) seems to hang in an odd way, in that HTTP calls made to the mock never complete.
I used ProcessExplorer to verify that
testhost.x86.exehad successfully opened the port, but any calls made to it (e.g., from a browser, from Postman) would have the connection hang at the "ESTABLISHED" phase, with no response ever being returned.I verified that the exact same code run directly from a net461 console app did work as expected, and did not exhibit this hang.
I downloaded and compiled WireMock directly, and was able to verify that the issue was Kestrel itself not firing any callbacks. I could see Kestrel starting up correctly, but no call ever seemed to get back out. I hacked up the source and verified this issue did no occur with the Owin-based host... only the Kestrel / AspNetCore host.
Eventually, I gave up trying to figure out what was wrong (nothing obvious in sight... perhaps something related to the multiple AppDomains & shared app domains the test runner uses?), and simply upgraded AspNetCore to the most recent 2.1.X series. This fixed the issue.
Perhaps some minor tweaks that might be made:
But... these are not really important to me, as I have things working now by manually setting the AspNetCore package in the test assembly to a recent version 😅 .
@StefH commented on GitHub (Dec 18, 2019):
I'll upgrade NuGet in PR https://github.com/WireMock-Net/WireMock.Net/pull/363