Table of Contents

Class XunitTestClass

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

Default implementation of IXunitTestClass for xUnit v3 tests based on reflection.

public class XunitTestClass : IXunitTestClass, ITestClass, ITestClassMetadata, IXunitSerializable
Inheritance
XunitTestClass
Implements
Inherited Members

Constructors

XunitTestClass()

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 XunitTestClass()

XunitTestClass(Type, IXunitTestCollection, string?)

Initializes a new instance of the XunitTestClass class.

public XunitTestClass(Type @class, IXunitTestCollection testCollection, string? uniqueID = null)

Parameters

class Type

The test class

testCollection IXunitTestCollection

The test collection the class belongs to

uniqueID string

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

Properties

BeforeAfterTestAttributes

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

public IReadOnlyCollection<IBeforeAfterTestAttribute> BeforeAfterTestAttributes { get; }

Property Value

IReadOnlyCollection<IBeforeAfterTestAttribute>

Class

Gets the type that this test class refers to.

public Type Class { get; }

Property Value

Type

Remarks

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

ClassFixtureTypes

Gets a list of class fixture types associated with the test class (and the test collection).

public IReadOnlyCollection<Type> ClassFixtureTypes { get; }

Property Value

IReadOnlyCollection<Type>

Constructors

Gets the public constructors on the test class. If the test class is static, will return null.

public IReadOnlyCollection<ConstructorInfo>? Constructors { get; }

Property Value

IReadOnlyCollection<ConstructorInfo>

Methods

Gets the public methods on the test class.

public IReadOnlyCollection<MethodInfo> Methods { get; }

Property Value

IReadOnlyCollection<MethodInfo>

TestCaseOrderer

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

public ITestCaseOrderer? TestCaseOrderer { get; }

Property Value

ITestCaseOrderer

TestClassName

Gets the full name of the test class (i.e., FullName).

public string TestClassName { get; }

Property Value

string

TestClassNamespace

Gets the namespace of the class where the test is defined. Will return null for classes not residing in a namespace.

public string? TestClassNamespace { get; }

Property Value

string

TestClassSimpleName

Gets the simple name of the test class (the class name without namespace).

public string TestClassSimpleName { get; }

Property Value

string

TestCollection

Gets the test collection this test class belongs to.

public IXunitTestCollection TestCollection { get; }

Property Value

IXunitTestCollection

Traits

Gets the trait values associated with this test class (and the test collection, and 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 class.

public string UniqueID { get; }

Property Value

string

Remarks

The unique identifier for a test class should be able to discriminate among test classes in the same test assembly. This identifier should remain stable until such time as the developer changes some fundamental part of the identity (assembly, collection, or test class). 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