Skip to content

Commit

Permalink
changing the output format to receive a list of formats
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasteles committed Dec 23, 2020
1 parent 0b6b25f commit 02774d6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion help/markdown/dotnet-testing-coverlet.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ DotNet.test (fun p ->
}
|> Coverlet.withDotNetTestOptions (fun p ->
{ p with
OutputFormat = Coverlet.OutputFormat.OpenCover
OutputFormat = [Coverlet.OutputFormat.OpenCover]
Output = "coverage.xml"
Include = [
// Include all namespaces from assemblies whose name starts with MyProject
Expand Down
10 changes: 7 additions & 3 deletions src/app/Fake.DotNet.Testing.Coverlet/Coverlet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type ThresholdStat =
/// Coverlet MSBuild parameters. For more details see: https://github.com/tonerdo/coverlet/blob/master/Documentation/MSBuildIntegration.md
type CoverletParams =
{ /// (Required) Format of the generated output.
OutputFormat : OutputFormat
OutputFormat : OutputFormat list
/// (Required) Path to the generated output file, or directory if it ends with a `/`.
Output : string
/// Namespaces to include, as (AssemblyName, Namespace) pairs. Supports `*` and `?` globbing.
Expand All @@ -51,7 +51,7 @@ type CoverletParams =

/// The default parameters.
let private defaults =
{ OutputFormat = OutputFormat.Json
{ OutputFormat = [OutputFormat.Json]
Output = "./"
Include = []
Exclude = []
Expand All @@ -70,6 +70,10 @@ let private outputFormatToString = function
| OutputFormat.Cobertura -> "cobertura"
| OutputFormat.TeamCity -> "teamcity"

let private outputFormatListToString =
List.map outputFormatToString
>> String.concat ","

let private namespacesToString =
Seq.map (fun (asm, ns) -> "[" + asm + "]" + ns)
>> String.concat ","
Expand All @@ -90,7 +94,7 @@ let withMSBuildArguments (param: CoverletParams -> CoverletParams) (args: MSBuil
let properties =
[
yield "CollectCoverage", "true"
yield "CoverletOutputFormat", outputFormatToString param.OutputFormat
yield "CoverletOutputFormat", outputFormatListToString param.OutputFormat
yield "CoverletOutput", param.Output
if not (List.isEmpty param.Include) then
yield "Include", namespacesToString param.Include
Expand Down
4 changes: 2 additions & 2 deletions src/test/Fake.Core.UnitTests/Fake.DotNet.Testing.Coverlet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let tests =
testCase "Test that full properties are converted" <| fun _ ->
let props = getProps (fun p ->
{
OutputFormat = Coverlet.OutputFormat.Cobertura
OutputFormat = [Coverlet.OutputFormat.Cobertura; Coverlet.OutputFormat.Json]
Output = "coverage.json"
Include = [
"Incl.Asm1", "Incl.Ns1"
Expand All @@ -38,7 +38,7 @@ let tests =
Expect.containsAll props [
"CollectCoverage", "true"
"CoverletOutput", "coverage.json"
"CoverletOutputFormat", "cobertura"
"CoverletOutputFormat", "cobertura,json"
"Include", "[Incl.Asm1]Incl.Ns1,[Incl.Asm2]Incl.Ns2"
"Exclude", "[Excl.Asm1]Excl.Ns1,[Excl.Asm2]Excl.Ns2"
"ExcludeByAttribute", "Attr1,Attr2"
Expand Down

0 comments on commit 02774d6

Please sign in to comment.