Table of Contents

Class Test

Namespace
NUnit.Framework.Internal
Assembly
nunit.framework.dll

The Test abstract class represents a test within the framework.

public abstract class Test : ITest, IXmlNodeBuilder, IComparable
Inheritance
Test
Implements
Derived
Inherited Members

Constructors

Test(MethodInfo)

Construct a test from a MethodInfo

protected Test(MethodInfo method)

Parameters

method MethodInfo

Test(string)

Constructs a test given its name

protected Test(string name)

Parameters

name string

The 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

pathName string

The parent tests full name

name string

The name of the test

Test(Type)

TODO: Documentation needed for constructor

protected Test(Type fixtureType)

Parameters

fixtureType Type

Fields

setUpMethods

The SetUp methods.

protected MethodInfo[] setUpMethods

Field Value

MethodInfo[]

tearDownMethods

The teardown methods

protected MethodInfo[] tearDownMethods

Field Value

MethodInfo[]

Properties

Fixture

Gets or sets a fixture object for running this test.

public object Fixture { get; set; }

Property Value

object

FixtureType

Gets the Type of the fixture used in running this test or null if no fixture type is associated with it.

public Type FixtureType { get; }

Property Value

Type

FullName

Gets or sets the fully qualified name of the test

public string FullName { get; set; }

Property Value

string

HasChildren

Gets a bool indicating whether the current test has any descendant tests.

public abstract bool HasChildren { get; }

Property Value

bool

Id

Gets or sets the id of the test

public int Id { get; set; }

Property Value

int

IsSuite

Returns true if this is a TestSuite

public bool IsSuite { get; }

Property Value

bool

Method

Gets a MethodInfo for the method implementing this test. Returns null if the test is not implemented as a method.

public MethodInfo Method { get; set; }

Property Value

MethodInfo

Name

Gets or sets the name of the test

public string Name { get; set; }

Property Value

string

Parent

Gets the parent as a Test object. Used by the core to set the parent.

public ITest Parent { get; set; }

Property Value

ITest

Properties

Gets the properties for this test

public IPropertyBag Properties { get; }

Property Value

IPropertyBag

RunState

Whether or not the test should be run

public RunState RunState { get; set; }

Property Value

RunState

Seed

Gets or Sets the Int value representing the seed for the RandomGenerator

public int Seed { get; set; }

Property Value

int

TestCaseCount

Gets a count of test cases represented by or contained under this test.

public virtual int TestCaseCount { get; }

Property Value

int

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

string

Tests

Gets this test's child tests

public abstract IList<ITest> Tests { get; }

Property Value

IList<ITest>

A list of child tests

XmlElementName

Gets the name used for the top-level element in the XML representation of this test

public abstract string XmlElementName { get; }

Property Value

string

Methods

AddToXml(XmlNode, bool)

Returns an XmlNode representing the current result after adding it as a child of the supplied parent node.

public abstract XmlNode AddToXml(XmlNode parentNode, bool recursive)

Parameters

parentNode XmlNode

The parent node.

recursive bool

If true, descendant results are included

Returns

XmlNode

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

An object implementing ICustomAttributeProvider

CompareTo(object)

Compares this test to another test for sorting purposes

public int CompareTo(object obj)

Parameters

obj object

The other test

Returns

int

Value of -1, 0 or +1 depending on whether the current test is less than, equal to or greater than the other test

MakeTestResult()

Creates a TestResult for this test.

public abstract TestResult MakeTestResult()

Returns

TestResult

A TestResult suitable for this type of test.

PopulateTestNode(XmlNode, bool)

Add standard attributes and members to a test node.

protected void PopulateTestNode(XmlNode thisNode, bool recursive)

Parameters

thisNode XmlNode
recursive bool

ToXml(bool)

Returns the Xml representation of the test

public XmlNode ToXml(bool recursive)

Parameters

recursive bool

If true, include child tests recursively

Returns

XmlNode