Table of Contents

Class XunitTestCollection

Namespace
Xunit.v3
Assembly
xunit.v3.core.dll

The default implementation of IXunitTestCollection for xUnit.net v3.

public class XunitTestCollection : IXunitTestCollection, ITestCollection, ITestCollectionMetadata, IXunitSerializable
Inheritance
XunitTestCollection
Implements
Inherited Members

Constructors

XunitTestCollection()

Called by the de-serializer; should only be called by deriving classes for de-serialization purposes

[Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")]
public XunitTestCollection()

XunitTestCollection(IXunitTestAssembly, Type?, bool, string, string?)

Initializes a new instance of the XunitTestCollection class.

public XunitTestCollection(IXunitTestAssembly testAssembly, Type? collectionDefinition, bool disableParallelization, string displayName, string? uniqueID = null)

Parameters

testAssembly IXunitTestAssembly

The test assembly the collection belongs to

collectionDefinition Type

The optional type which contains the collection definition

disableParallelization bool

A flag to indicate whether this test collection opts out of parallelization

displayName string

The display name for the test collection

uniqueID string

The unique ID for the test collection (only used to override default behavior in testing scenarios)

Properties

BeforeAfterTestAttributes

Gets the IBeforeAfterTestAttributes attached to the test collection (and the test assembly).

public IReadOnlyCollection<IBeforeAfterTestAttribute> BeforeAfterTestAttributes { get; }

Property Value

IReadOnlyCollection<IBeforeAfterTestAttribute>

ClassFixtureTypes

Gets a list of collection fixture types associated with the test collection.

public IReadOnlyCollection<Type> ClassFixtureTypes { get; }

Property Value

IReadOnlyCollection<Type>

CollectionDefinition

Gets the type that this collection definition derived from, if it derives from one. Untyped collections are possible when test classes are decorated using CollectionAttribute(string) and there is no test collection class declared with the same name.

public Type? CollectionDefinition { get; }

Property Value

Type

Remarks

This should only be used to execute a test collection. All reflection should be abstracted here instead for better testability.

CollectionFixtureTypes

Gets a list of collection fixture types associated with the test collection.

public IReadOnlyCollection<Type> CollectionFixtureTypes { get; }

Property Value

IReadOnlyCollection<Type>

DisableParallelization

Determines whether tests in this collection runs in parallel with any other collections.

public bool DisableParallelization { get; }

Property Value

bool

TestAssembly

Gets the test assembly this test collection belongs to.

public IXunitTestAssembly TestAssembly { get; }

Property Value

IXunitTestAssembly

TestCaseOrderer

Gets the test case orderer for the test collection, if present.

public ITestCaseOrderer? TestCaseOrderer { get; }

Property Value

ITestCaseOrderer

TestCollectionClassName

Gets the type that the test collection was defined with, if available; may be null if the test collection didn't have a definition type.

public string? TestCollectionClassName { get; }

Property Value

string

TestCollectionDisplayName

Gets the display name of the test collection.

public string TestCollectionDisplayName { get; }

Property Value

string

Traits

Gets the trait values associated with this test collection (and the test assembly). If there are none, or the framework does not support traits, this returns an empty dictionary (not null).

public IReadOnlyDictionary<string, IReadOnlyCollection<string>> Traits { get; }

Property Value

IReadOnlyDictionary<string, IReadOnlyCollection<string>>

UniqueID

Gets the unique ID for this test collection.

public string UniqueID { get; }

Property Value

string

Remarks

The unique identifier for a test collection should be able to discriminate among test collections in the same test assembly. This identifier should remain stable until such time as the developer changes some fundamental part of the identity (the test assembly, the collection definition class, or the collection name). Recompilation of the test assembly is reasonable as a stability changing event.

Methods

Deserialize(IXunitSerializationInfo)

Called when the object should populate itself with data from the serialization info.

public void Deserialize(IXunitSerializationInfo info)

Parameters

info IXunitSerializationInfo

The info to get the object data from

Serialize(IXunitSerializationInfo)

Called when the object should store its serialized values into the serialization info.

public void Serialize(IXunitSerializationInfo info)

Parameters

info IXunitSerializationInfo

The info to store the object data into