forked from pester/Pester
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPester.RSpec.BackCompat.ts.ps1
61 lines (48 loc) · 1.94 KB
/
Pester.RSpec.BackCompat.ts.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
param ([switch] $PassThru)
Get-Module Pester.Runtime, Pester.Utility, P, Pester, Axiom, Stack | Remove-Module
Import-Module $PSScriptRoot\p.psm1 -DisableNameChecking
Import-Module $PSScriptRoot\axiom\Axiom.psm1 -DisableNameChecking
& "$PSScriptRoot\..\build.ps1"
Import-Module $PSScriptRoot\..\bin\Pester.psd1
$global:PesterPreference = @{
Debug = @{
ShowFullErrors = $false
WriteDebugMessages = $false
WriteDebugMessagesFrom = "*Filter"
}
Output = @{ Verbosity = 'None' }
}
i -PassThru:$PassThru {
b "Backward compatibility for Invoke-Pester" {
t "Invoke-Pester Legacy parameter set" {
try {
$tmp = Join-Path ([IO.Path]::GetTempPath()) "simple$((Get-Date).Ticks)"
$null = New-Item -ItemType Directory -Force $tmp
$codeFile = Join-Path $tmp "code-file.ps1"
$testFile = Join-Path $tmp "simple.Tests.ps1"
$code = "function fff { 'hello' }"
$test = "
BeforeAll {
. $codeFile
}
Describe 'a' {
It 'b' { fff }
}"
$code | Set-Content $codeFile
$test | Set-Content $testFile
$tr = Join-Path $tmp "simple.TestResults.xml"
$cc = Join-Path $tmp "simple.Coverage.xml"
$r = Invoke-Pester -Script $testFile -PassThru -Verbose -OutputFile $tr -OutputFormat NUnitXml `
-CodeCoverage "$tmp/*-*.ps1" -CodeCoverageOutputFile $cc -Show All
$r.Containers[0].Blocks[0].Tests[0].Result | Verify-Equal "Passed"
Test-Path $tr | Verify-True
Test-Path $cc | Verify-True
}
finally {
if (Test-Path $tmp) {
Remove-Item -Path $tmp -Force -Recurse
}
}
}
}
}