sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Support Multiple Test Frameworks

Open TheRealPiotrP opened this issue 11 years ago • 10 comments

We will be adding a top-level TestRunner(s) property to project.json to allow for folks to select the runners that should be executed when they dotnet test. I don't see any reason why folks could not use multiple runners/frameworks in a given project [xunit + nunit, for example]. Supporting this, however, means that the property would be an array of 0+ elements:

{
    TestRunners: ["xunit.runner.dotnet", "nunit.runner.dotnet"]
}

The common scenario, however, will be a single runner, making the array syntax a bit of overhead. What do folks think?

/cc @davidfowl @anurse @brthor @Sridhar-MS @livarcocc @krwq @blackdwarf

TheRealPiotrP avatar Nov 17 '15 22:11 TheRealPiotrP

This raises a couple questions:

Does this mean dotnet test runs both xunit and nunit in order? or in parallel? Can I specify I only want one in some cases? Defaulting to all when not specified? How do I pass CLI params to xunit and nunit in one command?

natemcmaster avatar Nov 17 '15 23:11 natemcmaster

As far as the original question, if we decide to enable multiple test runners, I don't see a problem in the syntax. Docker has similar for ENTRYPOINT, for instance, and its not that big of a deal.

But, @natemcmaster actually raises a series of interesting ones, so we should work through those.

thesmithee avatar Nov 17 '15 23:11 thesmithee

great questions.

  1. Ordering: I planned to execute them in the order listed, one at a time
  2. Running one at a time: like with most top-level commands, dotnet-test will be backed by supporting commands like dotnet-test-xunit. These can be invoked directly.
  3. By default we would run all.
  4. Command Line Params: shall the array then become a dictionary?
"xunit":"cmd line arguments"

TheRealPiotrP avatar Nov 17 '15 23:11 TheRealPiotrP

What's the scenario for using multiple test runners in a single project? It seems a little like a solution looking for a problem to me.

analogrelay avatar Nov 18 '15 02:11 analogrelay

@anurse, I think that's the right answer. This issue is to challenge the assumption :)

TheRealPiotrP avatar Nov 18 '15 06:11 TheRealPiotrP

Yah, +1 @anurse multiple is weird.

davidfowl avatar Nov 18 '15 06:11 davidfowl

I figured someone just needed to say it ;P. Let's go with one, and we can always expand later. It's easy to have the test runner property be a single string now and add support for it being an array later.

As for command line arguments, I think we should work like DNX commands worked, just add the command line arguments to the string that is used for the runner. For example:

{
    "test": "xunit.runner.dotnet --someoption somevalue"
}

What if we used the existing scripts section to do this? In DNX we supported arbitrary commands for simple lifecycle events, and while dotnet does not support this yet, I'm adding it in now:

{
    "scripts": {
        "precompile": [ "echo About to compile...", "echo Preparing to compile...", "echo Now engaging compiler" ]
    }
}

What if we added a test script option? The tricky thing there is figuring out how to treat the value. Normally, the scripts in this section are shell commands, but for test we want it to identify a package dependency that has the entry point...

analogrelay avatar Nov 18 '15 16:11 analogrelay

okie, I'm making this a single-runner-per-project. Thanks for inptu!

TheRealPiotrP avatar Nov 23 '15 21:11 TheRealPiotrP

@piotrpMSFT , sorry to resurrect an old issue. I have used different test frameworks within a single test project several times. I tend to write mostly bdd style tests (mspec) but sometimes i'll also add in (for eg) xunit if I need theories or approvaltests for comparing result snapshots.

Is dotnet test supporting multiple test frameworks per project likely to happen at all or should i just create separate projects per test framework?

cheers

JustinThirkell avatar Dec 15 '16 09:12 JustinThirkell

@thirkcircus let's ask the @dotnet/vstest folks!

TheRealPiotrP avatar Dec 17 '16 09:12 TheRealPiotrP