Table of Contents

Class TestAttribute

Namespace
NUnit.Framework
Assembly
nunit.framework.dll

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

string

Description

Descriptive text for this test

public string? Description { get; set; }

Property Value

string

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

Type

Methods

ApplyToTest(Test)

Modifies a test by adding a description, if not already set.

public void ApplyToTest(Test test)

Parameters

test Test

The 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 IMethodInfo

The method for which a test is to be constructed.

suite Test

The suite to which the test will be added.

Returns

TestMethod