Skip to content

Instantly share code, notes, and snippets.

@lira92
Last active November 14, 2018 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lira92/13e4f3ac83b92d2dc340c6ff7dd4b917 to your computer and use it in GitHub Desktop.
Save lira92/13e4f3ac83b92d2dc340c6ff7dd4b917 to your computer and use it in GitHub Desktop.
Powershell to get all projects from path /test and run tests with coverage info.
if (-Not (Get-Command -Name reportgenerator -ErrorAction SilentlyContinue))
{
Write-Output "Instalando reportgenerator"
Invoke-Expression "dotnet tool install --global dotnet-reportgenerator-globaltool --version 4.0.0"
}
Write-Output "Listando arquivos csproj"
$reports = [System.Collections.ArrayList]@()
Get-ChildItem -Path .\test -Recurse -Filter *.csproj -File | ForEach-Object {
Write-Output "Executando testes para o projeto $($_.BaseName)/$($_.Name)"
Invoke-Expression "dotnet test ./test/$($_.BaseName)/$($_.Name) /p:CollectCoverage=true /p:CoverletOutputFormat=opencover"
$test = $reports.Add("./test/$($_.BaseName)/coverage.opencover.xml")
}
$reportsText = $reports -join ';'
Invoke-Expression "reportgenerator '-reports:$($reportsText)' '-targetdir:./report'"
Invoke-Item ./report/index.htm
Write-Host -NoNewLine 'Press any key to continue...';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment