Class TestAttribute
Adding this attribute to a method within a TestFixtureAttribute class makes the method callable from the NUnit test runner. There is a property called Description which is optional which you can provide a more detailed test description. This class cannot be inherited.
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class TestAttribute : NUnitAttribute, ISimpleTestBuilder, IApplyToTest, IImplyFixture
- Inheritance
-
TestAttribute
- Implements
- Inherited Members
Examples
[TestFixture] public class Fixture { [Test] public void MethodToTest() {}
[Test(Description = "more detailed description")] public void TestDescriptionMethod() {} }
Constructors
TestAttribute()
public TestAttribute()
Properties
Author
The author of this test
public string Author { get; set; }
Property Value
Description
Descriptive text for this test
public string Description { get; set; }
Property Value
ExpectedResult
Gets or sets the expected result.
public object ExpectedResult { get; set; }
Property Value
- object
The result.
HasExpectedResult
Returns true if an expected result has been set
public bool HasExpectedResult { get; }
Property Value
TestOf
The type that this test is testing
public Type TestOf { get; set; }
Property Value
Methods
ApplyToTest(Test)
Modifies a test by adding a description, if not already set.
public void ApplyToTest(Test test)
Parameters
test
TestThe test to modify
BuildFrom(MethodInfo, Test)
Construct a TestMethod from a given MethodInfo.
public TestMethod BuildFrom(MethodInfo method, Test suite)
Parameters
method
MethodInfoThe MethodInfo for which a test is to be constructed.
suite
TestThe suite to which the test will be added.
Returns
- TestMethod
A TestMethod