1

I would like to create test suite based on the tests defined in this repo:

https://github.com/json-schema/JSON-Schema-Test-Suite

The tests are defined in a number of json files, that can contain any number of tests.

Obviously I don't want to write a test for each test defined in this repo, I want to auto discover the tests and run them. But I would like to use a standard unit test framework like NUnit or xUnit. But if I just loop through all the files in a single test, then I don't get much info out of that. It will just be a single test that fails or passes in Jenkins or Team City. I could of course output all the relevant data, but that isn't nice.

Is there a way to make each test show up as a single unit test when running my test suite, without having to actually write each test method?

EDIT: I guess what I am looking for is something like xUnit ClassData like described here Pass complex parameters to [Theory]. But then my next question would be if I can have each test show up with different names ;)

What I needed to search for on Google was "data driven unit tests".

Community
  • 1
  • 1
Jay Pete
  • 4,123
  • 4
  • 35
  • 51

2 Answers2

1

NUnit TestCaseSource does exactly what I want it to.

@Kieren Johnstone I would prefer not doing code generation. I considered that and decided against it for the sake of simplicity.

Jay Pete
  • 4,123
  • 4
  • 35
  • 51
0

You could generate code using T4 templates or some other automatic means. The massive advantage here is that the tests themselves are already in a decent data structure (you couldn't line things up better than that!).

Kieren Johnstone
  • 41,277
  • 16
  • 94
  • 144