-
Notifications
You must be signed in to change notification settings - Fork 69
/
TestHarness.psm1
52 lines (41 loc) · 1.52 KB
/
TestHarness.psm1
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
45
46
47
48
49
50
51
52
function Invoke-TestHarness
{
[CmdletBinding()]
param
(
[System.String]
$TestResultsFile,
[System.String]
$DscTestsPath
)
Write-Verbose -Message 'Commencing all xCertificate tests'
$repoDir = Join-Path -Path $PSScriptRoot -ChildPath '..\' -Resolve
$testCoverageFiles = @()
Get-ChildItem -Path "$repoDir\modules\xCertificate\DSCResources\**\*.psm1" -Recurse | ForEach-Object {
if ($_.FullName -notlike '*\DSCResource.Tests\*') {
$testCoverageFiles += $_.FullName
}
}
$testResultSettings = @{ }
if ([String]::IsNullOrEmpty($TestResultsFile) -eq $false) {
$testResultSettings.Add('OutputFormat', 'NUnitXml' )
$testResultSettings.Add('OutputFile', $TestResultsFile)
}
Import-Module -Name "$repoDir\modules\xCertificate\xCertificate.psd1"
$testsToRun = @()
# Run Unit Tests
$unitTestsPath = Join-Path -Path $repoDir -ChildPath 'Tests\Unit'
$testsToRun += @( (Get-ChildItem -Path $unitTestsPath).FullName )
# Integration Tests
$integrationTestsPath = Join-Path -Path $repoDir -ChildPath 'Tests\Integration'
$testsToRun += @( (Get-ChildItem -Path $integrationTestsPath -Filter '*.Tests.ps1').FullName )
# DSC Common Tests
if ($PSBoundParameters.ContainsKey('DscTestsPath') -eq $true)
{
$testsToRun += @( $DscTestsPath )
}
$results = Invoke-Pester -Script $testsToRun `
-CodeCoverage $testCoverageFiles `
-PassThru @testResultSettings
return $results
}