You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using tuples as test-method input and the tuple member names don't match, MemberDataShouldReferenceValidMember generates type-mismatch errors like:
error xUnit1039: The type argument (System.DateTime a, System.DateTime b) from TestClass.Data is not compatible with the type of the corresponding test method parameter _
I consider this a false-positive because even when the member names don't match, the tests will still run correctly.
If the current behavior is deemed as desired, I would however recommend to improve the error message. Ideally the message could tell me, that the type matches but the tuple member names don't.
Examples
TheoryData<> does not define names for tuple members, but Test methods does
.. or vice versa.
using System.Collections.Generic;
using Xunit;
public class TestClass {
public static TheoryData<(int, int)> Data;
[MemberData(nameof(Data))]
public void TestMethod((int a, int b) _) { }
}
TheoryData<> defines a different name than test method
using System.Collections.Generic;
using Xunit;
public class TestClass {
public static TheoryData<(int a, int b)> Data;
[MemberData(nameof(Data))]
public void TestMethod((int a, int iUseAnotherNameHereWhichIMakeExtraLongToBeObvoius) _) { }
}
This Works
When the tuple member names match, there's no error:
using System.Collections.Generic;
using Xunit;
public class TestClass {
public static TheoryData<(int a, int b)> Data;
[MemberData(nameof(Data))]
public void TestMethod((int a, int b) _) { }
}
The text was updated successfully, but these errors were encountered:
When using tuples as test-method input and the tuple member names don't match,
MemberDataShouldReferenceValidMember
generates type-mismatch errors like:I consider this a false-positive because even when the member names don't match, the tests will still run correctly.
If the current behavior is deemed as desired, I would however recommend to improve the error message. Ideally the message could tell me, that the type matches but the tuple member names don't.
Examples
TheoryData<>
does not define names for tuple members, but Test methods does.. or vice versa.
TheoryData<>
defines a different name than test methodThis Works
When the tuple member names match, there's no error:
The text was updated successfully, but these errors were encountered: