Class TestAttribute
Marks the method as callable from the NUnit test runner.
[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. Not valid if the test method has parameters.
public object? ExpectedResult { get; set; }
Property Value
- object
The result.
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(IMethodInfo, Test?)
Builds a single test from the specified method and context.
public TestMethod BuildFrom(IMethodInfo method, Test? suite)
Parameters
method
IMethodInfoThe method for which a test is to be constructed.
suite
TestThe suite to which the test will be added.