Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't the NUnit Test Adapter find my FsUnit tests?

I'm using Visual Studio Professional 2015 and I have version 2.0.0.0 of the NUnit Test Adapter installed.

It doesn't discover any tests on building the following code:

namespace SmallestDivisibleIntegers

module Core =

    let f n = [2..4] |> List.map (fun x -> x + n - n % x)

module Tests =

    open FsUnit
    open NUnit.Framework

    open Core

    [<Test>]
    let ``Correct answers`` () =
        f 1 |> should equal [2; 3; 4]
        f 4 |> should equal [6; 6; 8]
        f 43 |> should equal [44; 45; 44]
        f 123 |> should equal [124; 126; 124]
        f 420 |> should equal [422; 423; 424]
        f 31415 |> should equal [31416; 31416; 31416]
        f 1081177 |> should equal [1081178; 1081179; 1081180]

    [<Test>]
    let ``simple test`` () =
        (1 + 1) |> should equal 2

I have referenced FsUnit (2.1.0) and NUnit (3.2.0) and the tests run fine in F# interactive.

How can I get the tests to appear in the Test Explorer?

like image 713
Mark Pattison Avatar asked May 18 '16 10:05

Mark Pattison


People also ask

What is the use of NUnit test adapter?

The NUnit Test Adapter allows you to run NUnit tests inside Visual Studio. The current release, version 0.92, is designed to work with the Visual Studio 11 Beta Release. Releases of Visual Studio prior to VS 11 did not have the ability to directly run tests built with Open Source testing frameworks like NUnit.

What is NUnit 3 test adapter?

The NUnit 3 Test Adapter allows you to run NUnit 3 tests inside Visual Studio or with dotnet on the command line. The current release is designed to work with Visual Studio 2012, 2013, 2015, 2017, 2019 and 2022. Some features are not available under VS2012 RTM.


1 Answers

I had the same problem and it is easy to make.

You are pre-supposing that there is only one NUnit Test Adapter and that it works for versions 2.x and 3.x of NUnit. However there are two versions of the NUnit Test Adapter

one for 2.x: NUnit Test Adapter

The NUnitTestAdapter extension works with the Visual Studio Unit Test window to allow integrated test execution under Visual Studio 2012, 2013 and 2015.

The latest version, 2.0, is based on NUnit 2.6.4 and is compatible with tests developed using NUnit 2.0 through 2.6.4. It supports all versions of VS2012, VS2013 and VS2015. You can find the release notes here

and one for 3.x: NUnit3 Test Adapter

The NUnit3TestAdapter extension works with the Visual Studio Unit Test window to allow integrated test execution under Visual Studio 2012, 2013 and 2015.

This adapter only works with NUnit 3.0. For use with earlier versions of NUnit use the NUnitTestAdapter (note - no 3) extension.

The current package is the first production release of version 3.0 of the adapter, using NUnit 3.0.1. You can find the documentation and release notes at https://github.com/nunit/docs/wiki

like image 168
Guy Coder Avatar answered Nov 07 '22 03:11

Guy Coder