Getting "option" error with xUnit2 target in FAKE build file
When I add the xUnit2 example to the FAKE build file, I get this error:
error FS0001: This expression is expected to be of type string but here is type string
Target example from FAKE xunit2 documentation
Target "Test" (fun _ ->
!! (testDir @@ "xUnit.Test.*.dll")
|> xUnit2 (fun p -> {p with HtmlOutputPath = (testDir @@ "xunit.html")})
)
Visual Studio highlights a section of (testDir @@ "xunit.html")
code.
I understand that it expects two parameters, but I don't know enough F # yet to figure out how to fix the problem:
Before enabling the xUnit target, my FAKE build was working fine. I added open Fake.Testing.XUnit2
to the assembly file and I am not getting the error with the xUnit2 link.
Any help would be appreciated.
source to share
So the error is that the type HtmlOutputPath
is
HtmlOutputPath : string option
In Fake I believe it @@
does Path.Combine
, so testDir @@ "xunit.html
must have a string like.
To match types you can use
HtmlOutputPath = Some(testDir @@ "xunit.html")
This suggests that the FAKE documentation is incorrect.
source to share