Table of Contents

Class CollectionAttribute

Namespace
Xunit
Assembly
xunit.v3.core.dll

Used to declare a specific test collection for a test class.

[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public sealed class CollectionAttribute : Attribute, ICollectionAttribute
Inheritance
CollectionAttribute
Implements
Inherited Members

Constructors

CollectionAttribute(string)

Initializes a new instance of the CollectionAttribute class, with the given collection name.

CollectionAttribute(Type)

Initializes a new instance of the CollectionAttribute class based on a collection definition type, with an auto-generated name based on that type. Equivalent to using CollectionAttribute<TCollectionDefinition>.

Properties

Name

Gets the name of the collection. If CollectionAttribute(string) was called, will return the provided name; if CollectionAttribute(Type) was called, will return a synthetic name for the type.

Type

Gets the collection definition type. Returns null if the collection is purely based on name.

Methods

GetCollectionNameForType(Type)

Gets the collection name that will result for a given type.