Class TestAttribute
Marks the method as callable from the NUnit test runner.
Inherited Members
Namespace: NUnit.Framework
Assembly: nunit.framework.dll
Syntax
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class TestAttribute : NUnitAttribute, ISimpleTestBuilder, IApplyToTest, IImplyFixture
Examples
[TestFixture] public class Fixture { [Test] public void MethodToTest() {}
[Test(Description = "more detailed description")] public void TestDescriptionMethod() {} }
Constructors
View SourceTestAttribute()
Declaration
public TestAttribute()
Properties
View SourceAuthor
The author of this test
Declaration
public string? Author { get; set; }
Property Value
Type | Description |
---|---|
string |
Description
Descriptive text for this test
Declaration
public string? Description { get; set; }
Property Value
Type | Description |
---|---|
string |
ExpectedResult
Gets or sets the expected result. Not valid if the test method has parameters.
Declaration
public object? ExpectedResult { get; set; }
Property Value
Type | Description |
---|---|
object | The result. |
TestOf
The type that this test is testing
Declaration
public Type? TestOf { get; set; }
Property Value
Type | Description |
---|---|
Type |
Methods
View SourceApplyToTest(Test)
Modifies a test by adding a description, if not already set.
Declaration
public void ApplyToTest(Test test)
Parameters
Type | Name | Description |
---|---|---|
Test | test | The test to modify |
BuildFrom(IMethodInfo, Test?)
Builds a single test from the specified method and context.
Declaration
public TestMethod BuildFrom(IMethodInfo method, Test? suite)
Parameters
Type | Name | Description |
---|---|---|
IMethodInfo | method | The method for which a test is to be constructed. |
Test | suite | The suite to which the test will be added. |
Returns
Type | Description |
---|---|
TestMethod |