-
Notifications
You must be signed in to change notification settings - Fork 744
FixtureLifeCycle(LifeCycle.InstancePerTestCase) Not working with TestFixtureSource #3715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I can confirm the bug, here's a refined example test that fails: [TestFixtureSource(nameof(FixtureArgs))]
[FixtureLifeCycle(LifeCycle.InstancePerTestCase)]
public class LifeCycleWithTestFixtureSourceTest
{
private readonly int _initialValue;
private int _value;
public LifeCycleWithTestFixtureSourceTest(int num)
{
_initialValue = num;
_value = num;
}
public static int[] FixtureArgs() => new[] { 1, 42 };
[Test]
public void Test1() => Assert.AreEqual(_initialValue, _value++);
[Test]
public void Test2() => Assert.AreEqual(_initialValue, _value++);
} |
@avilv since you worked on the original implementation would you mind taking a look at this? |
@rprouse any way to get a bug fix release instead of waiting until 3.14? |
@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. |
sounds great, thank you for your help. |
Fixed by #3720 |
Hi, i have same problem with TestCaseSource. Is it fixed by this bug to? |
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. |
#3720 does not seem to fix the following: [FixtureLifeCycle(LifeCycle.InstancePerTestCase)]
[Parallelizable(ParallelScope.All)]
public class FixtureLifeCycleTests
{
private int _counter = 0;
[TestCase(0)]
[TestCase(1)]
[TestCase(2)]
[TestCase(3)]
public void WorksWithTestCaseAttribute(int _)
{
Assert.AreEqual(1, Interlocked.Increment(ref _counter));
}
} |
@ivan-menshikov this issue relates specifically to TestFixtureSource parametrization. I have created a new issue #3743, that addresses this new case as well. |
I'm using the new
FixtureLifeCycle(LifeCycle.InstancePerTestCase)
withTestFixtureSource
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 anIDisposable
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 anIDisposable
class and stopping the server in theDispose
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.
The text was updated successfully, but these errors were encountered: