Search code examples
unit-testingf#fsunit

running fsUnit tests from visual studio


So i wrote my first fsUnit test in Visual studio. It is just an extension to the NUnit framework and I have been using NUnit from doing TDD in C#. While writing tests in c#, I am able to run the tests from visual studio But I am not able to run f# tests from VS. why is this ? Are there any other tools which i can use to run the tests (externally)?


Solution

  • fsUnit is just a library that allows you to write the body of the unit test using combinators, but the rest of the unit test can be written as a usual class (with the usual attributes). If you write something like the following then the NUnit test runner should see it (e.g. in a file Tests.fs in some project):

    open FsUnit
    open NUnit.Framework
    
    [<TestFixture>]
    type AccountTest() =
      [<Test>]
      member x.SimpleTest() = 
        1 |> should equal 1