我使用FAKE作为构建工具,但我必须承认我是一个相当新的F#函数式编程
为了运行我的测试,我使用以下代码:
trace "BuildTests..."
!! "Tests/**.Tests/*.csproj"
|> Seq.iter (fun p ->
[p]
|> MSBuildDebug (testDir @@ Path.GetFileNameWithoutExtension(p)) "Build"
|> Log "TestBuild-Output: "
)
trace "RunTests..."
!! (testDir + "**/*.Tests.dll")
|> MSTest (fun p ->
{ p with
TestSettingsPath = testSettingsPath
ResultsDir = artifactsDir
ErrorLevel = ErrorLevel.DontFailBuild })
Run Code Online (Sandbox Code Playgroud)
但现在我想用OpenCover而不是MSTest来运行我的测试.基本上,对OpenCover的调用是
OpenCover (fun p ->
{ p with
Output=(artifactsDir + "output.xml")
OptionalArguments = "-excludebyfile:*Designer.* -returntargetcode" })
"/testcontainer:Path.To.First.Test.dll /testcontainer:Path.To.Second.Test.dll"
Run Code Online (Sandbox Code Playgroud)
所以我的问题是如何将FileInclude结果转换!! (testDir + "**/*.Tests.dll")为组合字符串
/testcontainer:file1.dll /testcontainer:file2.dll /testcontainer:file3.dll
Run Code Online (Sandbox Code Playgroud)
所以我可以将它与OpenCover Task一起使用
与你的相似
!! "Tests/**.Tests/*.csproj"
|> Seq.iter (fun p ->
Run Code Online (Sandbox Code Playgroud)
将Seqeuence转换为数组并连接它.
!! (testDir + "**/*.Tests.dll")
|> Seq.toArray
|> String.concat " "
Run Code Online (Sandbox Code Playgroud)