NUnit 3.13.3
I Have a following test method:
[TestCaseSource(nameof(_myTestMethodCases))]
public void MyTestMethod(string text, int number, params Cat[] cats)
{
foreach(var cat in cats)
{
// Do stuff
}
// Do other stuff
// Assert
}
And a following field representing test cases:
private static object[] _myTestMethodCases
{
new object[] { "testA", 10, new Cat("Lua"), new Cat("Julia") }
new object[] { "testB", 20 }
new object[] { "testC", 20, new Cat("Ruby") }
}
But when i try to run test i get an exception: Not enough arguments provided, provide at least 3 arguments.
in all cases.
How can I make it work, except creating a method as TestCaseSource?
This is a known bug in TestCaseSource, at least in some versions of NUnit. Just add new Cat[0] as the third argument to TestB.