Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. param(
  2. [Parameter(Mandatory=$true)]
  3. [string]$testProjectPath,
  4. [Parameter(Mandatory=$true)]
  5. [string]$testSettingsPath,
  6. [Parameter(Mandatory=$true)]
  7. [string]$testResultsFolder
  8. )
  9.  
  10. <#
  11. echo "Test Project Path" $testProjectPath
  12. echo "Test Settings Path" $testSettingsPath
  13. echo "Test Results Folder" $testResultsFolder
  14. #>
  15.  
  16. try {
  17.  
  18. if (-not (Test-Path $testProjectPath))
  19. {
  20. throw [System.IO.FileNotFoundException] "$testProjectPath not found."
  21. }
  22. if (-not (Test-Path $testSettingsPath))
  23. {
  24. throw [System.IO.FileNotFoundException] "$testSettingsPath not found."
  25. }
  26. if (-not (Test-Path $testResultsFolder))
  27. {
  28. throw [System.IO.FileNotFoundException] "$testResultsFolder not found."
  29. }
  30.  
  31. dotnet test $testProjectPath --settings:$testSettingsPath
  32. $recentCoverageFile = Get-ChildItem -File -Filter *.coverage -Path $testResultsFolder -Name -Recurse | Select-Object -First 1;
  33. write-host 'Test Completed' -ForegroundColor Green
  34.  
  35. C:\Users\krishnamohan\.nuget\packages\microsoft.codecoverage\15.9.0\build\netstandard1.0\CodeCoverage\CodeCoverage.exe analyze /output:$testResultsFolder\MyTestOutput.coveragexml $testResultsFolder'\'$recentCoverageFile
  36. write-host 'CoverageXML Generated' -ForegroundColor Green
  37.  
  38. dotnet C:\Users\krishnamohan\.nuget\packages\reportgenerator\4.1.10\tools\netcoreapp2.1\ReportGenerator.dll "-reports:$testResultsFolder\MyTestOutput.coveragexml" "-targetdir:$testResultsFolder\coveragereport"
  39. write-host 'CoverageReport Published' -ForegroundColor Green
  40.  
  41. }
  42. catch {
  43.  
  44. write-host "Caught an exception:" -ForegroundColor Red
  45. write-host "Exception Type: $($_.Exception.GetType().FullName)" -ForegroundColor Red
  46. write-host "Exception Message: $($_.Exception.Message)" -ForegroundColor Red
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement