1

I want to create tests using NUnit which parameters is multidimensional array. I've read a documentation (https://github.com/nunit/docs/wiki/TestCaseSource-Attribute) But my code doesn't work. Can somebody explain why?

static IEnumerable<int[,]> TestMatrixs()
{
     yield return new int[4, 2] { { 1, 2 }, { 3, 4 }, { 5, 3 }, { 7, 9 } };
}

[TestCaseSource(nameof(TestMatrixs))]
public void TestCreateSquareMatrixPower2(int[,] matrixSource)
{
    Assert.NotNull(matrixSource);
}

There is an error "there are no available tests" (in all test class). If I delete test method with TestCaseSource all another methods work fine. I've tryed to create another class, as mentioned in documentation, but it wasn't work too. How can I create test with parameters of multidimensional array?

Maksim Simkin
  • 9,561
  • 4
  • 36
  • 49
Galina Melnik
  • 1,947
  • 3
  • 14
  • 19
  • I don't know what are you doing wrong. I have tested your code and it works fine, i have unit tests and i get exact the matrix you have defined in test as parameter – Maksim Simkin Jun 14 '19 at 09:40
  • your code works fine and test passes. on my computer too. check the recommendations in this question: https://stackoverflow.com/questions/49495900/vs2017-and-nunit-3-9-no-test-is-available – Barış Akkurt Jun 14 '19 at 11:31
  • 1
    Works fine for me too. Make sure you are using the latest version of NUnit 3.12 and if you are running in Visual Studio, the latest version of the NUnit adapter. I added your code to the TestCaseSourceTests in the nunit-v3 project in this repo if you want to see for yourself, https://github.com/rprouse/nunit-tests – Rob Prouse Jun 15 '19 at 11:32
  • @RobProuse Thank you. I used NUnit 3.10.1 . Just change version to 3.12.0 and everything works fine. – Galina Melnik Jun 18 '19 at 12:20

0 Answers0