Running NUnit3 tests using fake

Reading time ~1 minute

When you have some unit tests developed using NUnit 2.x your FAKE script looks like something like this:

1
2
3
4
Target "RunUnitTests" (fun _ ->
    !! (testDir + "/*.Tests.dll")
    |> NUnit (fun p ->
          {p with ToolPath = "packages/NUnit.Runners/tools/"}) )

But NUnit3 works slightly different. Instead of having a single NUnit.Runners package, that package references some other packages (runner, extensions, etc). One of those packages is NUnit.ConsoleRunner that has the exe inside the tools folder.

But changing the ToolPath in the FAKE task is not enough. You should use the new NUnit3 action, which is inside the Fake.Testing module. So, we need to open the module and change the task definition:

1
2
3
4
5
6
let nunitRunnerPath = "packages/NUnit.ConsoleRunner/tools/nunit3-console.exe"

Target "RunUnitTests" (fun _ ->
    !! (testDir + "/*.Tests.dll")
    |> NUnit3 (fun p ->
        {p with ToolPath = nunitRunnerPath}) )

And hopefully when you run the FAKE script you’ll have something like this:

NUnit3 Results

A simple Azure Function using F#

The other day my friend [Jero](https://twitter.com/jerolba) wrote an [article](http://www.jerolba.com/mujeres-y-hombres-y-serverless/) ex...… Continue reading

Definition of X

Published on March 24, 2017

Cargo cult

Published on March 16, 2017