TestFixture
TestFixture is a surrogate for a user test fixture class,
containing one or more tests.
using NUnit.Framework.Interfaces;
using System;
using System.Runtime.CompilerServices;
namespace NUnit.Framework.Internal
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
public class TestFixture : TestSuite, IDisposableFixture
{
public LifeCycle LifeCycle { get; set; }
public new ITypeInfo TypeInfo => base.TypeInfo;
public TestFixture(ITypeInfo fixtureType, [System.Runtime.CompilerServices.Nullable(2)] object[] arguments = null)
: base(fixtureType, arguments)
{
base.SetUpMethods = TypeInfo.GetMethodsWithAttribute<SetUpAttribute>(true);
base.TearDownMethods = TypeInfo.GetMethodsWithAttribute<TearDownAttribute>(true);
base.OneTimeSetUpMethods = TypeInfo.GetMethodsWithAttribute<OneTimeSetUpAttribute>(true);
base.OneTimeTearDownMethods = TypeInfo.GetMethodsWithAttribute<OneTimeTearDownAttribute>(true);
CheckSetUpTearDownMethods(base.OneTimeSetUpMethods);
CheckSetUpTearDownMethods(base.OneTimeTearDownMethods);
CheckSetUpTearDownMethods(base.SetUpMethods);
CheckSetUpTearDownMethods(base.TearDownMethods);
}
private TestFixture(TestFixture fixture, ITestFilter filter)
: base(fixture, filter)
{
}
public TestFixture(ITypeInfo fixtureType, Exception ex)
: base(fixtureType, null)
{
MakeInvalid(ex, "Failure building TestFixture");
}
public override TestSuite Copy(ITestFilter filter)
{
return new TestFixture(this, filter);
}
}
}