Closed neoistheone123 closed 8 years ago
Hi @ykeysergit, Can you reproduce it ? and send me the test suite ?
Thanks.
Yes. Consistently. The test suite is like...
public void Test1(){ var server = fixture.createServer() try{ } finally{ server.Dispose(); } }
public void Test2(){ var server = fixture.createServer() try{
} finally{ server.Dispose(); } }
Seems like there's a thread in the framework which is still running.
What is behind fixture.createServer ?
A correct usage example is here https://github.com/hibri/HttpMock/blob/master/src/HttpMock.Integration.Tests/HttpFactoryTests.cs and here
I suggest sharing the mock server between tests, to avoid the cost of destroying and recreating the port that the server listens on. This can be an expensive operation. Dispose might not guarantee the port is released for use in time for the next test.
You can use .WithNewContext to clear the stubs that were setup in a previous tests. Create the server in a TestFixtureSetup (before all tests), and call .WithNewContext in a SetUp method before each test.
Hope this helps :)
I did this so I can use AssertWasCall with different expectations. Otherwise, the success of one test case may propogate to the next. I'll try WithNewContext.
createServer: IHttpServer server = HttpMockRepository.At(hostUrl); stubX(server); return server;
FYI, I'm using XUnit.
I think it may be due to something due to how I created the server. Stand by.
Ok. The root cause is on my end. Thanks for your input!
I have a test suite which creates/disposes a server multiple times. Server.IsAvailable() returns true, but the HTTP request hangs until timeout. When I ran the tests individually, they pass.