Table of Contents

Class CategoryAttribute

Namespace
NUnit.Framework
Assembly
nunit.framework.dll

Attribute used to apply a category to a test

[AttributeUsage(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public class CategoryAttribute : NUnitAttribute, IApplyToTest
Inheritance
CategoryAttribute
Implements
Inherited Members

Constructors

CategoryAttribute()

Protected constructor uses the Type name as the name of the category.

protected CategoryAttribute()

CategoryAttribute(string)

Construct attribute for a given category based on a name. The name may not contain the characters ',', '+', '-' or '!'. However, this is not checked in the constructor since it would cause an error to arise at as the test was loaded without giving a clear indication of where the problem is located. The error is handled in NUnitFramework.cs by marking the test as not runnable.

public CategoryAttribute(string name)

Parameters

name string

The name of the category

Fields

categoryName

The name of the category

protected string categoryName

Field Value

string

Properties

Name

The name of the category

public string Name { get; }

Property Value

string

Methods

ApplyToTest(Test)

Modifies a test by adding a category to it.

public void ApplyToTest(Test test)

Parameters

test Test

The test to modify