forked from PowerShell/DscResource.Tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestRunner.psm1
42 lines (32 loc) · 1.06 KB
/
TestRunner.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
<#
.SYNOPSIS
Runs all tests (including common tests) on all DSC resources in the given folder.
.PARAMETER ResourcesPath
The path to the folder containing the resources to be tested.
.EXAMPLE
Start-DscResourceTests -ResourcesPath C:\DscResources\DscResources
#>
function Start-DscResourceTests
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)]
[String]
$ResourcesPath
)
$testsPath = $pwd
Push-Location -Path $ResourcesPath
Get-ChildItem | ForEach-Object {
$moduleName = $_.Name
$destinationPath = Join-Path -Path $ResourcesPath -ChildPath $moduleName
Write-Verbose -Message "Copying common tests from $testsPath to $destinationPath"
Copy-Item -Path $testsPath -Destination $destinationPath -Recurse -Force
Push-Location -Path $moduleName
Write-Verbose "Running tests for $moduleName"
Invoke-Pester
Pop-Location
}
Pop-Location
}
Export-ModuleMember -Function @( 'Start-DscResourceTests' )