-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRunPSCodeHealth.ps1
44 lines (39 loc) · 1.33 KB
/
RunPSCodeHealth.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Need to import all the files first of course.
Set-Location "C:\OPEN_PROJECTS\ClarityPS\"
$FoundError = $false
$Directories = ("private", "public")
foreach ($Directory in $Directories)
{
# Import the functions.
$PSCodeHealthParameters = @{
Path = ".\ClarityPS\$Directory\"
TestsPath = ".\tests\$Directory\"
HtmlReportPath = ".\Test_Results\PowerRestCLI_$Directory.html"
PassThru = $true
}
$DirectoryResults = Invoke-PSCodeHealth @PSCodeHealthParameters
if ($DirectoryResults.CommandsMissedTotal -ne 0)
{
$MissedCommands = $DirectoryResults.CommandsMissedTotal
$FoundError = $true
Write-Output "Missed Commands for Directory: $Directory - ($MissedCommands)"
}
if ($DirectoryResults.NumberOfFailedTests -ne 0)
{
$FailedTests
$FoundError = $true
Write-Output "Failed Tests for Directory: $Directory - ($FailedTests)"
}
# Open the Report in the default web browser.
Start-Process (".\Test_Results\PowerRestCLI_$Directory.html")
}
if ($FoundError -eq $true)
{
# An error was found in the Unit tests.
Write-Error "An error has been found in the unit Tests. Please review them before commiting the code."
}
else
{
# No Errors found. Hooray!
Write-Output "Tests cover 100% and all pass! Hooray!"
}