Table of Contents

Class XunitTestAssembly

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

The default implementation of IXunitTestAssembly for xUnit.net v3.

public class XunitTestAssembly : IXunitTestAssembly, ITestAssembly, IAssemblyMetadata, IXunitSerializable
Inheritance
XunitTestAssembly
Implements
Inherited Members

Constructors

XunitTestAssembly()

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

XunitTestAssembly(Assembly, string?, Version?, string?)

Initializes a new instance of the XunitTestAssembly class.

public XunitTestAssembly(Assembly assembly, string? configFileName = null, Version? version = null, string? uniqueID = null)

Parameters

assembly Assembly

The test assembly.

configFileName string

The optional configuration filename

version Version

The version number of the assembly (defaults to "0.0.0.0")

uniqueID string

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

Properties

Assembly

Gets the assembly of this test assembly.

public Assembly Assembly { get; }

Property Value

Assembly

Remarks

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

AssemblyFixtureTypes

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

public IReadOnlyCollection<Type> AssemblyFixtureTypes { get; }

Property Value

IReadOnlyCollection<Type>

AssemblyName

Gets the assembly name. May return a simple assembly name (i.e., "mscorlib"), or may return a fully qualified name (i.e., "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089").

public string AssemblyName { get; }

Property Value

string

AssemblyPath

Gets the on-disk location of the assembly under test.

public string AssemblyPath { get; }

Property Value

string

BeforeAfterTestAttributes

Gets the IBeforeAfterTestAttributes attached to the test assembly.

public IReadOnlyCollection<IBeforeAfterTestAttribute> BeforeAfterTestAttributes { get; }

Property Value

IReadOnlyCollection<IBeforeAfterTestAttribute>

CollectionBehavior

Gets the collection behavior associated with the assembly, if present.

public ICollectionBehaviorAttribute? CollectionBehavior { get; }

Property Value

ICollectionBehaviorAttribute

CollectionDefinitions

Gets the collection definitions attached to the test assembly, by collection name.

public IReadOnlyDictionary<string, (Type Type, CollectionDefinitionAttribute Attribute)> CollectionDefinitions { get; }

Property Value

IReadOnlyDictionary<string, (Type Type, CollectionDefinitionAttribute Attribute)>

ConfigFilePath

Gets the full path of the configuration file name, if one is present. May be null if there is no configuration file.

public string? ConfigFilePath { get; }

Property Value

string

ModuleVersionID

Returns the module version ID of the test assembly. Used as the basis for randomization.

public Guid ModuleVersionID { get; }

Property Value

Guid

TargetFramework

Gets the target framework the test assembly was compiled against. Will be in a form like ".NETFramework,Version=v4.7.2" or ".NETCoreApp,Version=v6.0".

public string TargetFramework { get; }

Property Value

string

TestCaseOrderer

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

public ITestCaseOrderer? TestCaseOrderer { get; }

Property Value

ITestCaseOrderer

TestCollectionOrderer

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

public ITestCollectionOrderer? TestCollectionOrderer { get; }

Property Value

ITestCollectionOrderer

Traits

Gets the trait values associated with this test assembly. If there are none, or the framework does not support traits, this should return 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 assembly.

public string UniqueID { get; }

Property Value

string

Remarks

The unique identifier for a test assembly should be able to discriminate among test assemblies with their associated configuration file (so the same assembly with two different configuration files should have two different unique IDs). This identifier should remain stable until such time as the developer changes some fundamental part of the identity. Recompilation of the test assembly is reasonable as a stability changing event.

Version

Gets the assembly version.

public Version Version { get; }

Property Value

Version

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