How do you use multiple TestCaseSource attributes to supply test data to a test in N-Unit 2.62?
I'm currently doing the following:
[Test, Combinatorial, TestCaseSource(typeof(FooFactory), "GetFoo"), TestCaseSource(typeof(BarFactory), "GetBar")]
FooBar(Foo x, Bar y)
{
//Some test runs here.
}
And my test case data sources look like this:
internal sealed class FooFactory
{
public IEnumerable<Foo> GetFoo()
{
//Gets some foos.
}
}
internal sealed class BarFactory
{
public IEnumerable<Bar> GetBar()
{
//Gets some bars.
}
}
Unfortunately, N-Unit won't even kick off the test since it says I'm supplying the wrong number of arguments. I know you can specify a TestCaseObject as the return type and pass in an object array, but I thought that this approach was possible.
Can you help me resolve this?
The appropriate attribute to use in this situation is ValueSource
. Essentially, you are specifying a data-source for every argument, like so.
public void TestQuoteSubmission(
[ValueSource(typeof(FooFactory), "GetFoo")] Foo x,
[ValueSource(typeof(BarFactory), "GetBar")] Bar y)
{
// Your test here.
}
This will enable the type of functionality I was looking for using the TestCaseSource
attribute.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With