You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FixtureLifeCycle(LifeCycle.InstancePerTestCase) Not working with TestFixtureSource #3715
I'm using the new FixtureLifeCycle(LifeCycle.InstancePerTestCase) with TestFixtureSource and am running into an issue where a new instance is not created.
At first, I thought this might be an issue with WireMock.Net but it works fine without TestFixtureSource. It also works fine when using an IDisposable class to simulate setup/teardown per test as @jnm2 has mentioned in the past.
In my tests, I am using WireMock.Net to create a new instance of the mock server for each test. Before FixtureLifeCycle, I was starting the server in the constructor of an IDisposable class and stopping the server in the Dispose method.
In my tests below I'm just writing out the URL of the mock server to show that they are using the same url:port. Each test should start a server on a unique port number but both tests are using the same port.
usingNUnit.Framework;usingSystem;usingSystem.Collections;usingSystem.Linq;usingWireMock.Server;namespaceNUnitTestProject1{[TestFixture][Parallelizable(ParallelScope.All)][FixtureLifeCycle(LifeCycle.InstancePerTestCase)][TestFixtureSource(typeof(BrowserData))]publicclassTestBase{protectedWireMockServerServer{get;set;}protectedstringdriverId;publicTestBase(stringdriver){driverId=driver;}[SetUp]publicvoidBeforeTest(){Server=WireMockServer.Start();}[TearDown]publicvoidAfterTest(){Server?.Stop();}}publicclassTests:TestBase{publicTests(stringdriver):base(driver){}[Test]publicvoidTest1(){TestContext.Out.WriteLine(Server.Urls.First());}[Test]publicvoidTest2(){TestContext.Out.WriteLine(Server.Urls.First());}}publicclassBrowserData:IEnumerable{privatereadonlystring[]_drivers;publicBrowserData(){vardriverId="LocalChrome";_drivers=Array.ConvertAll(driverId.Split(",",StringSplitOptions.RemoveEmptyEntries), d =>d.Trim());}publicIEnumeratorGetEnumerator(){return_drivers.GetEnumerator();}}}
Activity
gleb-osokin commentedon Jan 11, 2021
I can confirm the bug, here's a refined example test that fails:
xadvfh commentedon Jan 11, 2021
@avilv since you worked on the original implementation would you mind taking a look at this?
xadvfh commentedon Jan 13, 2021
@rprouse any way to get a bug fix release instead of waiting until 3.14?
rprouse commentedon Jan 13, 2021
@xadvfh I'm planning on doing a 3.13.1 release soon. I'm just tracking a few other bugs and giving it a bit of time for others to come to light.
xadvfh commentedon Jan 13, 2021
sounds great, thank you for your help.
rprouse commentedon Jan 23, 2021
Fixed by #3720
Lisaj commentedon Jan 25, 2021
Hi, i have same problem with TestCaseSource. Is it fixed by this bug to?
uchagani commentedon Jan 25, 2021
It is fixed but we’re waiting on a release which should be by the end of this month. I’m not sure if it has made its way into the nightly build.
ivan-menshikov commentedon Jan 25, 2021
#3720 does not seem to fix the following:
gleb-osokin commentedon Jan 26, 2021
@ivan-menshikov this issue relates specifically to TestFixtureSource parametrization.
I have created a new issue #3743, that addresses this new case as well.