Leo Shine
Leo Shine

Reputation: 23

Does xUnit.net support overriding the names of individual rows of a Theory?

In xUnit it is possible to have parameterized unit tests (theories).

E.g.

[Theory]
[InlineData(1,2)]
[InlineData(2,4)]
[InlineData(-1,-2)]
public void DoublingWorks(int a, int b)
{
    Assert.Equal(a+a,b);
}

However I can't see how override the name of the test, e.g. above I might like to make the name for the negative example "negative" to reflect it's different nature rather than being "DoublingWorks(a: -1, b: -2)". Is there a different type of attribute that I need to use to get this feature? Also can I selectively Ignore the test cases? Can I get it to work with the MemberDataAttribute too?

Upvotes: 1

Views: 621

Answers (1)

Dominik Lemberger
Dominik Lemberger

Reputation: 2426

It is possible by overwriting the toString() Function .. but other than this, its not currently possible.

https://github.com/xunit/xunit/issues/649

Here the github Link to the answer from the XUnit Developer

Upvotes: 1

Related Questions