Table of Contents

Interface IXunitTestMethod

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

Represents a test class from xUnit.net v3 based on reflection.

public interface IXunitTestMethod : ITestMethod, ITestMethodMetadata
Inherited Members

Properties

BeforeAfterTestAttributes

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

IReadOnlyCollection<IBeforeAfterTestAttribute> BeforeAfterTestAttributes { get; }

Property Value

IReadOnlyCollection<IBeforeAfterTestAttribute>

DataAttributes

Gets the IDataAttributes attached to the test method.

IReadOnlyCollection<IDataAttribute> DataAttributes { get; }

Property Value

IReadOnlyCollection<IDataAttribute>

FactAttributes

Gets the IFactAttributes attached to the test method.

IReadOnlyCollection<IFactAttribute> FactAttributes { get; }

Property Value

IReadOnlyCollection<IFactAttribute>

IsGenericMethodDefinition

Gets a flag which indicates whether this is a generic method definition.

bool IsGenericMethodDefinition { get; }

Property Value

bool

Method

Gets the method that this test method refers to.

MethodInfo Method { get; }

Property Value

MethodInfo

Remarks

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

Parameters

Gets the parameters of the test method.

IReadOnlyCollection<ParameterInfo> Parameters { get; }

Property Value

IReadOnlyCollection<ParameterInfo>

ReturnType

Gets the return type of the test method.

Type ReturnType { get; }

Property Value

Type

TestClass

Gets the test class that this test method belongs to.

IXunitTestClass TestClass { get; }

Property Value

IXunitTestClass

TestMethodArguments

Gets the arguments that will be passed to the test method.

object?[] TestMethodArguments { get; }

Property Value

object[]

Methods

GetDisplayName(string, object?[]?, Type[]?)

Gets the display name for the test method, factoring in arguments and generic types.

string GetDisplayName(string baseDisplayName, object?[]? testMethodArguments, Type[]? methodGenericTypes)

Parameters

baseDisplayName string

The base display name.

testMethodArguments object[]

The test method arguments.

methodGenericTypes Type[]

The generic types of the method.

Returns

string

MakeGenericMethod(Type[])

Creates a generic version of the test method with the given generic types.

MethodInfo MakeGenericMethod(Type[] genericTypes)

Parameters

genericTypes Type[]

The generic types

Returns

MethodInfo

ResolveGenericTypes(object?[])

Resolves the generic types for the test method given the method's arguments. If the method is not generic, will return null.

Type[]? ResolveGenericTypes(object?[] arguments)

Parameters

arguments object[]

The method arguments

Returns

Type[]

ResolveMethodArguments(object?[])

Resolves argument values for the test method, ensuring they are the correct type, including support for optional method arguments.

object?[] ResolveMethodArguments(object?[] arguments)

Parameters

arguments object[]

The test method arguments

Returns

object[]