tasks/testing.tasks.ps1

# Control flags
$EnableCoverage = $true

# Options
$ReportGeneratorToolVersion = "4.8.3"

# Synopsis: Run .NET solution tests
task RunTests {
    exec { 
        dotnet test $SolutionToBuild `
                    --configuration $Configuration `
                    --no-build `
                    --no-restore `
                    /p:CollectCoverage="$EnableCoverage" `
                    /p:CoverletOutputFormat=cobertura `
                    /p:ExcludeByFile="$($ExcludeFilesFromCodeCoverage.Replace(",","%2C"))" `
                    --verbosity $LogLevel
    }
}

# Synopsis: Generate test report file
task GenerateTestReport {
    Install-DotNetTool -Name "dotnet-reportgenerator-globaltool" -Version $ReportGeneratorToolVersion
    exec {
        reportgenerator "-reports:$SourcesDir/**/**/coverage.cobertura.xml" `
                        "-targetdir:$CoverageDir" `
                        "-reporttypes:$TestReportTypes"
    }
}