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
IDisposable not working with InstancePerTestCase #3773
using System;
using System.Buffers;
using NUnit.Framework;
namespace Foo
{
[FixtureLifeCycle(LifeCycle.InstancePerTestCase)]
[TestFixture(256)]
[TestFixture(1024)]
[Parallelizable(scope: ParallelScope.All)]
public class FixtureTests : IDisposable
{
private byte[] _buffer;
public FixtureTests(int bufferSize) => _buffer = ArrayPool<byte>.Shared.Rent(bufferSize);
public void Dispose() => ArrayPool<byte>.Shared.Return(_buffer);
[TestCase(0)]
[TestCase(256)]
public void Foo_Test(int size)
{
Assert.AreEqual(size, size);
}
}
}
I would expect the above to create and dispose the fixture per test case but it is resulting in an exception from NUnit
Failed Foo_Test(0) [127 ms]
Error Message:
System.InvalidOperationException : DisposeFixtureCommand does not apply neither to TestMethod, nor to ParameterizedMethodSuite
Stack Trace:
at NUnit.Framework.Guard.OperationValid(Boolean condition, String message)
at NUnit.Framework.Internal.Commands.DisposeFixtureCommand..ctor(TestCommand innerCommand)
at NUnit.Framework.Internal.Execution.SimpleWorkItem.MakeTestCommand()
at NUnit.Framework.Internal.Execution.SimpleWorkItem.PerformWork()
Activity
feryatolcay commentedon Mar 1, 2021
Hi @rprouse
Did you find the problem. I have same problem now and I don't know why?
Thanks
rprouse commentedon Mar 1, 2021
We haven't got to this yet, sorry.