<PackageReference Include="NUnit" Version="4.2.2" />

FixturePerTestCaseCommand

ConstructFixtureCommand constructs the user test object if necessary.
using NUnit.Framework.Interfaces; using System.Runtime.CompilerServices; namespace NUnit.Framework.Internal.Commands { public class FixturePerTestCaseCommand : BeforeTestCommand { [System.Runtime.CompilerServices.NullableContext(1)] public FixturePerTestCaseCommand(TestCommand innerCommand) : base(innerCommand) { TestFixture testFixture = null; ITest test = base.Test; while (test != null && testFixture == null) { testFixture = (test as TestFixture); test = test.Parent; } Guard.ArgumentValid(testFixture != null, "FixturePerTestCaseCommand must reference a TestFixture", "innerCommand"); ITypeInfo typeInfo = testFixture.TypeInfo; BeforeTest = delegate(TestExecutionContext context) { if (typeInfo != null && !typeInfo.IsStaticClass) { context.TestObject = typeInfo.Construct(testFixture.Arguments); base.Test.Fixture = context.TestObject; } }; } } }