Do you absolutely need to have the same signature for your method, i.e.
public void MyTestMethod(int a, int b, int[][] r) {
Depending on your situation, you have two options, both of which use the [TestCase] attribute, as you said you want in the question
Is this possible using only the TestCase attribute?
I prefer the first option, as it looks more concise, but both will suit your needs.
Option 1: If you do not need to keep the same signature
You can slightly modify the signature so that instead of an array (and not compilation time constants) you pass a string ( which is a compilation time constant ) that you can use to get an array, for example
private static int[][] getArrayForMyTestMethod(string key) { // logic to get from key to int[][] } [TestCase(5, 1, "dataset1")] public void MyTestMethod(int a, int b, string rKey) { int[][] r = getArrayForMyTestMethod(rKey); // elided }
Option 2: If you want to keep the same signature
If the method needs to keep the same signature, you can have a wrapper method that does the same as parameter 1, i.e.
private static int[][] getArrayForMyTestMethod(string key) { // logic to get from key to int[][] } [TestCase(5, 1, "dataset1")] public void MyTestMethodWrapper(int a, int b, string rKey) { int[][] r = getArrayForMyTestMethod(rKey); MyTestMethod(a, b, r); } public void MyTestMethod(int a, int b, int[][] r) { // elided }
Obviously, you can use any type, which may be a compile-time constant instead of string depending on how you create test cases, but I suggested string because you could give your test case a name in the NUnit runner that way.
Otherwise, your alternative is to use [TestCaseSource] , as you mentioned in your question.