Code Inspection: NUnit. Test case source must be static
Starting from NUnit 3.x, the TestCaseSource or ValueSource attribute argument representing the name of the source must refer to the static field, property or method. For example:
public class MyTestClass
{
[TestCaseSource("DivideCases")]
public void DivideTest(int n, int d, int q)
{
Assert.AreEqual(q, n / d);
}
static object[] DivideCases =
{
new object[] { 12, 3, 4 },
new object[] { 12, 2, 6 },
new object[] { 12, 4, 3 }
};
}
Last modified: 21 July 2022