Class Test
The Test abstract class represents a test within the framework.
public abstract class Test : ITest, IXmlNodeBuilder, IComparable, IComparable<Test>
- Inheritance
-
Test
- Implements
- Derived
- Inherited Members
Constructors
Test(IMethodInfo)
Constructs a test for a specific method.
protected Test(IMethodInfo method)
Parameters
method
IMethodInfo
Test(ITypeInfo)
Constructs a test for a specific type.
protected Test(ITypeInfo typeInfo)
Parameters
typeInfo
ITypeInfo
Test(string)
Constructs a test given its name
protected Test(string name)
Parameters
name
stringThe name of the test
Test(string?, string)
Constructs a test given the path through the test hierarchy to its parent and a name.
protected Test(string? pathName, string name)
Parameters
Properties
Arguments
The arguments to use in creating the test or empty array if none required.
public abstract object?[] Arguments { get; }
Property Value
- object[]
ClassName
Gets the name of the class where this test was declared. Returns null if the test is not associated with a class.
public string? ClassName { get; }
Property Value
Fixture
Gets or sets a fixture object for running this test.
public virtual object? Fixture { get; set; }
Property Value
FullName
Gets or sets the fully qualified name of the test
public string FullName { get; set; }
Property Value
HasChildren
Gets a bool indicating whether the current test has any descendant tests.
public abstract bool HasChildren { get; }
Property Value
Id
Gets or sets the id of the test
public string Id { get; set; }
Property Value
IdPrefix
Static prefix used for ids in this AppDomain. Set by FrameworkController.
public static string? IdPrefix { get; set; }
Property Value
IsSuite
Returns true if this is a TestSuite
public bool IsSuite { get; }
Property Value
Method
Gets a MethodInfo for the method implementing this test. Returns null if the test is not implemented as a method.
public IMethodInfo? Method { get; set; }
Property Value
MethodName
Gets the name of the method implementing this test. Returns null if the test is not implemented as a method.
public virtual string? MethodName { get; }
Property Value
Name
Gets or sets the name of the test
public string Name { get; set; }
Property Value
Parent
Gets the parent as a Test object. Used by the core to set the parent.
public ITest? Parent { get; set; }
Property Value
Properties
Gets the properties for this test
public IPropertyBag Properties { get; }
Property Value
RunState
Whether or not the test should be run
public RunState RunState { get; set; }
Property Value
Seed
Gets or Sets the Int value representing the seed for the RandomGenerator
public int Seed { get; set; }
Property Value
SetUpMethods
The SetUp methods.
public IMethodInfo[] SetUpMethods { get; protected set; }
Property Value
TearDownMethods
The teardown methods
public IMethodInfo[] TearDownMethods { get; protected set; }
Property Value
TestCaseCount
Gets a count of test cases represented by or contained under this test.
public virtual int TestCaseCount { get; }
Property Value
TestType
Gets a string representing the type of test. Used as an attribute value in the XML representation of a test and has no other function in the framework.
public virtual string TestType { get; }
Property Value
Tests
Gets this test's child tests
public abstract IList<ITest> Tests { get; }
Property Value
TypeInfo
Gets the TypeInfo of the fixture used in running this test or null if no fixture type is associated with it.
public ITypeInfo? TypeInfo { get; }
Property Value
XmlElementName
Gets the name used for the top-level element in the XML representation of this test
public abstract string XmlElementName { get; }
Property Value
Methods
AddToXml(TNode, bool)
Returns an XmlNode representing the current result after adding it as a child of the supplied parent node.
public abstract TNode AddToXml(TNode parentNode, bool recursive)
Parameters
Returns
ApplyAttributesToTest(ICustomAttributeProvider)
Modify a newly constructed test by applying any of NUnit's common attributes, based on a supplied ICustomAttributeProvider, which is usually the reflection element from which the test was constructed, but may not be in some instances. The attributes retrieved are saved for use in subsequent operations.
public void ApplyAttributesToTest(ICustomAttributeProvider provider)
Parameters
provider
ICustomAttributeProvider
ApplyAttributesToTest(Type)
Recursively apply the attributes on type
to this test,
including attributes on nesting types.
public void ApplyAttributesToTest(Type type)
Parameters
type
TypeThe
CompareTo(Test?)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
public int CompareTo(Test? other)
Parameters
other
TestAn object to compare with this instance.
Returns
CompareTo(object?)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
public int CompareTo(object? obj)
Parameters
obj
objectAn object to compare with this instance.
Returns
GetCustomAttributes<TAttr>(bool)
Get custom attributes applied to a test
public virtual TAttr[] GetCustomAttributes<TAttr>(bool inherit) where TAttr : class
Parameters
inherit
bool
Returns
- TAttr[]
Type Parameters
TAttr
GetNestedTypes(Type)
Returns all nested types, inner first.
protected IEnumerable<Type> GetNestedTypes(Type inner)
Parameters
inner
Type
Returns
MakeInvalid(Exception, string)
Mark the test as Invalid (not runnable) specifying a reason and an exception.
public void MakeInvalid(Exception exception, string reason)
Parameters
exception
ExceptionThe exception that was the cause.
reason
stringThe reason the test is not runnable
MakeInvalid(string)
Mark the test as Invalid (not runnable) specifying a reason
public void MakeInvalid(string reason)
Parameters
reason
stringThe reason the test is not runnable
MakeTestResult()
Creates a TestResult for this test.
public abstract TestResult MakeTestResult()
Returns
- TestResult
A TestResult suitable for this type of test.
PopulateTestNode(TNode, bool)
Add standard attributes and members to a test node.
protected void PopulateTestNode(TNode thisNode, bool recursive)
Parameters
ToXml(bool)
Returns the XML representation of the test
public TNode ToXml(bool recursive)
Parameters
recursive
boolIf true, include child tests recursively