My Technical Notes

Monday, 1 February 2016

F# Unit Testing

Because there is no "Unit Test Project" template for F#, we have to set it up ourselves:

  • Create a Class Library Project
  • Add a reference to `Microsoft.VisualStudio.QualityTools.UnitTestFramework`
  • To create a test class, we only need to decorate our classes and methods with attributes from the above unit testing DLL reference:

namespace FSharpStringUtils.Tests

open Microsoft.VisualStudio.TestTools.UnitTesting;
open FSharpStringUtils;

[<TestClass>]
namespace FSharpStringUtils.Tests

open Microsoft.VisualStudio.TestTools.UnitTesting;
open FSharpStringUtils;

[<TestClass>]
type StringUtilsTests() = 
    [<TestMethod>]
    member this.breakStringTest () = 
        let xs = StringUtils.breakString [""] 21
        ()

No comments: