AArnott / Xunit.Combinatorial

Adds combinatorial and pairwise testing capability to Xunit tests
Other
180 stars 16 forks source link

CombinatorialMemberData for strings does not work #54

Closed siewers closed 1 year ago

siewers commented 1 year ago

The following example throws an exception in xUnit:

public static readonly IEnumerable<string> StringFieldValues = Enumerable.Range(0, 5).Select(_ => Random.Next().ToString());

[Theory, CombinatorialData]
public void Test([CombinatorialMemberData(nameof(StringFieldValues))] string stringValue)
{
    Assert.True(true);
}

https://github.com/AArnott/Xunit.Combinatorial/blob/4b8210355b78548a73c191ea9b97fa81dc6c5de0/src/Xunit.Combinatorial/CombinatorialMemberDataAttribute.cs#L221-L225

The assertion should ensure that the member doesn't return IEnumerable<object[]>, which it doesn't, but it just seems to be wrong.

I guess an explicit check on whether the enumerated type is object[] would do the trick. I'm not completely sure what the condition exactly tries to evaluate and it's a bit confusing to me.

I was probably the one who implemented support for combinatorial member data, so I can give it a shot on fixing this problem :)

By the way, xUnit throws System.NotSupportedException : Specified method is not supported., which looks to be a bug also reported here.