Search Results for

    Show / Hide Table of Contents

    Class TestAttribute

    Marks the method as callable from the NUnit test runner.

    Inheritance
    object
    Attribute
    NUnitAttribute
    TestAttribute
    Implements
    ISimpleTestBuilder
    IApplyToTest
    IImplyFixture
    Inherited Members
    Attribute.GetCustomAttributes(MemberInfo, Type)
    Attribute.GetCustomAttributes(MemberInfo, Type, bool)
    Attribute.GetCustomAttributes(MemberInfo)
    Attribute.GetCustomAttributes(MemberInfo, bool)
    Attribute.IsDefined(MemberInfo, Type)
    Attribute.IsDefined(MemberInfo, Type, bool)
    Attribute.GetCustomAttribute(MemberInfo, Type)
    Attribute.GetCustomAttribute(MemberInfo, Type, bool)
    Attribute.GetCustomAttributes(ParameterInfo)
    Attribute.GetCustomAttributes(ParameterInfo, Type)
    Attribute.GetCustomAttributes(ParameterInfo, Type, bool)
    Attribute.GetCustomAttributes(ParameterInfo, bool)
    Attribute.IsDefined(ParameterInfo, Type)
    Attribute.IsDefined(ParameterInfo, Type, bool)
    Attribute.GetCustomAttribute(ParameterInfo, Type)
    Attribute.GetCustomAttribute(ParameterInfo, Type, bool)
    Attribute.GetCustomAttributes(Module, Type)
    Attribute.GetCustomAttributes(Module)
    Attribute.GetCustomAttributes(Module, bool)
    Attribute.GetCustomAttributes(Module, Type, bool)
    Attribute.IsDefined(Module, Type)
    Attribute.IsDefined(Module, Type, bool)
    Attribute.GetCustomAttribute(Module, Type)
    Attribute.GetCustomAttribute(Module, Type, bool)
    Attribute.GetCustomAttributes(Assembly, Type)
    Attribute.GetCustomAttributes(Assembly, Type, bool)
    Attribute.GetCustomAttributes(Assembly)
    Attribute.GetCustomAttributes(Assembly, bool)
    Attribute.IsDefined(Assembly, Type)
    Attribute.IsDefined(Assembly, Type, bool)
    Attribute.GetCustomAttribute(Assembly, Type)
    Attribute.GetCustomAttribute(Assembly, Type, bool)
    Attribute.Equals(object)
    Attribute.GetHashCode()
    Attribute.Match(object)
    Attribute.IsDefaultAttribute()
    Attribute.TypeId
    object.GetType()
    object.MemberwiseClone()
    object.ToString()
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    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 Source

    TestAttribute()

    Declaration
    public TestAttribute()

    Properties

    View Source

    Author

    The author of this test

    Declaration
    public string? Author { get; set; }
    Property Value
    Type Description
    string
    View Source

    Description

    Descriptive text for this test

    Declaration
    public string? Description { get; set; }
    Property Value
    Type Description
    string
    View Source

    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.

    View Source

    TestOf

    The type that this test is testing

    Declaration
    public Type? TestOf { get; set; }
    Property Value
    Type Description
    Type

    Methods

    View Source

    ApplyToTest(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

    View Source

    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

    Implements

    ISimpleTestBuilder
    IApplyToTest
    IImplyFixture
    • View Source
    In this article
    Back to top Generated by DocFX | Copyright (c) 2018- The NUnit Project - Licensed under CC BY-NC-SA 4.0