Search code examples
f#fsunit

When making a test class with FsUnit, [<Test>] is not a valid attribute on a member. Why?


I'm fiddling with a new F# project (of which I haven't made many), and I'm aiming to do it in a TDD fashion. So, I'm trying to familiarize myself with using FsUnit, since I have a lot of experience using NUnit in C# projects, and it seems a pretty common framework to use.

My code looks like the following:

module DatabaseReaderTest

open NUnit.Framework
open FsUnit

[<TestFixture>]
type DatabaseReaderTest ()=

    [<Test>]
    member x.ResultsAreReturnedFromDatabase =
        DatabaseReader.result.GetSqlString(1) |> should equal "first"

As far as I can tell, this follows the example on the FsUnit home page (http://fsunit.codeplex.com/), but the compiler tells me that [<Test>] is not a valid attribute on this language element, by which I assume it means member.

Any tips on what I'm doing wrong here?

Thanks!


Solution

  • You probably need to use a method rather than a property. Just add a () argument of type unit.