ptilton
ptilton

Reputation: 132

Getting "option" missing error with xUnit2 target in FAKE build file

When I add the example xUnit2 target to my FAKE build file, I'm getting this error:

error FS0001: This expression was expected to have type string option but here has type string

Target Example from FAKE xunit2 documentation

Target "Test" (fun _ ->
    !! (testDir @@ "xUnit.Test.*.dll")
      |> xUnit2 (fun p -> {p with HtmlOutputPath = (testDir @@ "xunit.html")})
)

The Visual Studio is highlighting the (testDir @@ "xunit.html") section of the code.

I understand that it's expecting two parameters, but I don't know enough F# yet to figure out how to fix the problem:

Prior to including the xUnit target, my FAKE build was working fine. I've added open Fake.Testing.XUnit2 to the build file and I get no error with the xUnit2 reference.

Any help would be appreciated.

Upvotes: 3

Views: 217

Answers (1)

John Palmer
John Palmer

Reputation: 25516

So the error is that the type of HtmlOutputPath is

HtmlOutputPath : string option

In Fake I believe that @@ does Path.Combine so testDir @@ "xunit.html should have type string.

To get the types to match, you can use

HtmlOutputPath = Some(testDir @@ "xunit.html")

This suggests that the documentation for FAKE is incorrect.

Upvotes: 3

Related Questions