Table of Contents

Interface IDataAttribute

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

Base interface that all data attributes (that is, data providers for theories) are expected to implement. Data attributes are valid on methods only.

public interface IDataAttribute

Properties

Explicit

Gets a value that determines whether the data rows provided by this data provider should be considered explicit or not. If true, then the data rows will all be considered explicit; if false, then the data rows will all be considered not explicit; if null, then the data rows will inherit their explicitness from Explicit.

bool? Explicit { get; }

Property Value

bool?

Skip

Gets a skip reason for all the data rows provided by this data provider. If not null, then all rows will be skipped with the given reason; if null, then the rows will inherit their skip reason from Skip.

string? Skip { get; }

Property Value

string

TestDisplayName

Gets the test display name for the test (replacing the default behavior, which would be to use DisplayName, or falling back to generating display names based on TestMethodDisplay and TestMethodDisplayOptions).

string? TestDisplayName { get; }

Property Value

string

Timeout

Gets a value to determine if the data rows provided by this data provider should include a timeout (in milliseconds). If greater than zero, the data rows will have the given timeout; if zero or less, the data rows will not have a timeout; if null, the data rows will inherit their timeout from Timeout.

int? Timeout { get; }

Property Value

int?

Traits

Gets a set of traits for the associated data. The data is provided as an array of string values that are alternating keys and values (e.g., ["key1", "value1", "key2", "value2"]).

string[]? Traits { get; }

Property Value

string[]

Remarks

This is structured as an array because attribute initializers don't support dictionaries. Note: Setting an odd number of values will throw away the unmatched key at the end of the list. If you seem to be missing your a key/value pair or have misaligned keys and values, make sure you have an even number of strings alternating between keys and values.

Methods

GetData(MethodInfo, DisposalTracker)

Returns the data to be used to test the theory.

ValueTask<IReadOnlyCollection<ITheoryDataRow>> GetData(MethodInfo testMethod, DisposalTracker disposalTracker)

Parameters

testMethod MethodInfo

The test method the data attribute is attached to

disposalTracker DisposalTracker

The disposal tracker used to dispose the data

Returns

ValueTask<IReadOnlyCollection<ITheoryDataRow>>

SupportsDiscoveryEnumeration()

Returns true if the data attribute supports enumeration during discovery; false otherwise. Data attributes with expensive computational costs and/or randomized data sets should return false.

bool SupportsDiscoveryEnumeration()

Returns

bool