When creating Theory test cases with XUnit I would like to be able to include both the parameters and the expected outcome for each case. I have used the InlineData attribute but for heavy configuration loading this is less than optimal and does not permit reuse.
[InlineData(1,2,3,4,5,6,7,...)]
As such I have moved the test configurations out to a separate class and now load them with MemberData and MemberType.
[Theory]
[MemberData(nameof(DataClass.Data), MemberType = typeof(DataClass))]
public void TestValidConfig(Configuration config)
{
...
}
However this does not allow me to specify the expected outcome like i could if using a basic tag i.e.
[InlineData("Input1", "Input2", "Input3", "ExpectedResult")]
I don't want to include the expected outcome with the configuration data as this will be reused in multiple tests.
Has anyone got a solution to this challenge?
So the underlying challenge is having complex test data, that could be used in multiple places, but then wanting to separate the expected outcome. So in a calculator (bad example) you could have lists of numbers that are the test data. These could then be passed into an add or multiply or subtraction test. This is where I would want to separate the input and the expected output data.