Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing coverlet output format to receive a list of formats #2562

Merged
merged 3 commits into from
May 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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