Skip to content

Commit 67ea932

Browse files
authored
Merge v4 (pester#1512)
1 parent 0fa8da3 commit 67ea932

30 files changed

+746
-74
lines changed

BACKERS.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Pester sponsors on GitHub
2+
3+
@cgalery
4+
@stevenjudd
5+
@ChrisLGardner
6+
@techthoughts2
7+
@omiossec
8+
@devblackops
9+
@mczerniawski
10+
@shaneis
11+
@MarvTheRobot
12+
@LaurentDardenne
13+
@piotrbanas
14+
@lazywinadmin
15+
@janegilring
16+
@rchaganti
17+
@BartekR
18+
@tabs-not-spaces
19+
@avanreijn
20+
@DevOpsCollectiveINC

azure-pipelines.yml

+35-6
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ trigger:
33
pr:
44
- v5.0
55

6-
resources:
7-
- repo: self
8-
clean: true
9-
fetchDepth: 1
10-
116
variables:
127
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
138
CI: 1
@@ -16,20 +11,26 @@ stages:
1611
- stage: Build
1712
jobs:
1813
- job: build
14+
workspace:
15+
clean: all
1916
pool:
2017
name: Default
2118
demands:
2219
- net452
2320
- netcoreapp3.1
2421
timeoutInMinutes: 3
2522
steps:
26-
- powershell: ./build.ps1
23+
- checkout: self
24+
fetchDepth: 1
25+
- powershell: ./build.ps1 -Clean
2726
- publish: $(Build.SourcesDirectory)
2827
artifact: all
2928

3029
- stage: Test
3130
jobs:
3231
- job:
32+
workspace:
33+
clean: all
3334
strategy:
3435
matrix:
3536
PS7_Ubuntu_16_04:
@@ -73,7 +74,22 @@ stages:
7374
script: |
7475
& ./test.ps1 -CI -PassThru -NoBuild
7576
workingDirectory: '$(Build.SourcesDirectory)'
77+
- task: PublishCodeCoverageResults@1
78+
inputs:
79+
codeCoverageTool: 'JaCoCo'
80+
summaryFileLocation: 'coverage.xml'
81+
pathToSources: 'src/'
82+
failIfCoverageEmpty: true
83+
condition: succeededOrFailed()
84+
- task: PublishTestResults@2
85+
inputs:
86+
testResultsFormat: 'NUnit'
87+
testResultsFiles: 'testResults.xml'
88+
failTaskOnFailedTests: true
89+
condition: succeededOrFailed()
7690
- job:
91+
workspace:
92+
clean: all
7793
strategy:
7894
matrix:
7995
PS3:
@@ -104,3 +120,16 @@ stages:
104120
script: |
105121
& ./test.ps1 -CI -PassThru -NoBuild
106122
workingDirectory: '$(Build.SourcesDirectory)'
123+
- task: PublishCodeCoverageResults@1
124+
inputs:
125+
codeCoverageTool: 'JaCoCo'
126+
summaryFileLocation: 'coverage.xml'
127+
pathToSources: 'src/'
128+
failIfCoverageEmpty: true
129+
condition: succeededOrFailed()
130+
- task: PublishTestResults@2
131+
inputs:
132+
testResultsFormat: 'NUnit'
133+
testResultsFiles: 'testResults.xml'
134+
failTaskOnFailedTests: true
135+
condition: succeededOrFailed()

build.ps1

+17-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
param (
44
[switch]$Debug,
55
[switch]$Load,
6-
[switch]$Clean)
6+
[switch]$Clean
7+
)
78

89
$ErrorActionPreference = 'Stop'
910
Get-Module Pester | Remove-Module
@@ -74,22 +75,30 @@ foreach ($s in $script) {
7475

7576
$sb.ToString() | Set-Content $PSScriptRoot/bin/Pester.psm1 -Encoding UTF8
7677

77-
dotnet build "$PSScriptRoot/src/csharp/Pester.sln" --configuration Release
78-
if (0 -ne $LASTEXITCODE) {
79-
throw "build failed!"
78+
if ($Clean) {
79+
dotnet build "$PSScriptRoot/src/csharp/Pester.sln" --configuration Release
80+
if (0 -ne $LASTEXITCODE) {
81+
throw "build failed!"
82+
}
8083
}
8184

8285
$content = @(
8386
,("$PSScriptRoot/src/en-US/*.txt","$PSScriptRoot/bin/en-US/")
8487
,("$PSScriptRoot/src/nunit_schema_2.5.xsd", "$PSScriptRoot/bin/")
88+
,("$PSScriptRoot/src/junit_schema_4.xsd", "$PSScriptRoot/bin/")
8589
,("$PSScriptRoot/src/report.dtd", "$PSScriptRoot/bin/")
8690
,("$PSScriptRoot/src/Pester.psd1", "$PSScriptRoot/bin/")
87-
,("$PSScriptRoot/src/csharp/bin/Release/net452/Pester.dll","$PSScriptRoot/bin/bin/net452/")
88-
,("$PSScriptRoot/src/csharp/bin/Release/net452/Pester.pdb","$PSScriptRoot/bin/bin/net452/")
89-
,("$PSScriptRoot/src/csharp/bin/Release/netstandard2.0/Pester.dll","$PSScriptRoot/bin/bin/netstandard2.0/")
90-
,("$PSScriptRoot/src/csharp/bin/Release/netstandard2.0/Pester.pdb","$PSScriptRoot/bin/bin/netstandard2.0/")
9191
)
9292

93+
if ($Clean) {
94+
$content += @(
95+
,("$PSScriptRoot/src/csharp/bin/Release/net452/Pester.dll","$PSScriptRoot/bin/bin/net452/")
96+
,("$PSScriptRoot/src/csharp/bin/Release/net452/Pester.pdb","$PSScriptRoot/bin/bin/net452/")
97+
,("$PSScriptRoot/src/csharp/bin/Release/netstandard2.0/Pester.dll","$PSScriptRoot/bin/bin/netstandard2.0/")
98+
,("$PSScriptRoot/src/csharp/bin/Release/netstandard2.0/Pester.pdb","$PSScriptRoot/bin/bin/netstandard2.0/")
99+
)
100+
}
101+
93102
foreach ($c in $content) {
94103
$source, $destination = $c
95104

docs/CHANGELOG.md

+39
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
1+
## 4.10.1 (February 7, 2020)
2+
3+
- Fix link in nuspec
4+
5+
## 4.10.0 (February 2, 2020)
6+
7+
- Remove all banners
8+
- Fix path in TestRegistry check
9+
- Remove drives on invocation and handle io error
10+
- Update link to Pester limitations [#1440](https://github.com/pester/pester/pull/1440)
11+
- Fix Get-Help links [#1432](https://github.com/pester/pester/pull/1432)
12+
- Handle the case when the failure message contains an escape sequence [#1426](https://github.com/pester/pester/pull/1426)
13+
- Remove logo from header because it is noisy [#1428](https://github.com/pester/pester/pull/1428)
14+
- Fix JaCoCo report so it can be processed by Codecov.io [#1420](https://github.com/pester/pester/pull/1420)
15+
- get-help: fix broken links [#1417](https://github.com/pester/pester/pull/1417)
16+
- docs: fix dyslexic PS prompt [#1415](https://github.com/pester/pester/pull/1415)
17+
- Skip symlink tests
18+
- Adds code fencing to the multi-line Get-Help code examples [#1413](https://github.com/pester/pester/pull/1413)
19+
- Add wiki lockdown note and call for help
20+
- Fixed incorrect variable used for hooks with tags in Invoke-GherkinHook. [#1400](https://github.com/pester/pester/pull/1400)
21+
- Upgrade AppVeyor image for PS Core test to 'Visual Studio 2019' to upgrade PS Core from 6.1 to 6.2 [#1368](https://github.com/pester/pester/pull/1368)
22+
- Add an Example of Should Be with an Array [#1396](https://github.com/pester/pester/pull/1396)
23+
- Handle when exceptions have no error messages. [#1382](https://github.com/pester/pester/pull/1382)
24+
- Write header only when Header flag is specified [#1378](https://github.com/pester/pester/pull/1378)
25+
- Invoke Set-ScriptBlockHint indirectly [#1371](https://github.com/pester/pester/pull/1371)
26+
- Added financial contributors to the README [#1363](https://github.com/pester/pester/pull/1363)
27+
28+
## 4.9.0 (September 8, 2019)
29+
30+
- Add JUnit format for results [#1347](https://github.com/pester/Pester/pull/1347)
31+
- Add skip reason to nUnit output [#1353](https://github.com/pester/Pester/pull/1353)
32+
- Add header with Pester version to output [#1343](https://github.com/pester/Pester/pull/1343)
33+
- Fix detect variable and params conflicts [#1292](https://github.com/pester/Pester/pull/1292)
34+
- Fix signing of ps1xml files
35+
36+
## 4.8.1 (May 11, 2019)
37+
38+
- Fix default parameter comparison on v2 [#1310](https://github.com/pester/Pester/pull/1310)
39+
140
## 4.8.0 (May 1, 2019)
241

342
- Add parameter to remove validation when mocking [#1278](https://github.com/pester/Pester/pull/1278)

docs/images/devopscollective.png

7.47 KB
Loading

docs/images/pester_blue_darker.pdf

-26 KB
Binary file not shown.
-48.1 KB
Binary file not shown.

publish/Pester.nuspec

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
<id>Pester</id>
55
<version>$version$</version>
66
<title>Pester</title>
7-
<summary>A BDD style testing tool for PowerShell</summary>
8-
<description>Pester provides a framework for running BDD style Tests to execute and validate PowerShell commands inside of PowerShell and offers a powerful set of Mocking Functions that allow tests to mimic and mock the functionality of any command inside of a piece of PowerShell code being tested. Pester tests can execute any command or script that is accessible to a pester test file. This can include functions, Cmdlets, Modules and scripts. Pester can be run in ad hoc style in a console or it can be integrated into the Build scripts of a Continuous Integration system.</description>
7+
<summary>Pester is the ubiquitous test and mock framework for PowerShell</summary>
8+
<description>Pester is testing framework for PowerShell, written in PowerShell.</description>
99
<tags>powershell unit testing bdd tdd mocking admin</tags>
1010
<authors>Pester Team</authors>
11-
<iconUrl>http://pesterbdd.com/images/Pester.png</iconUrl>
11+
<iconUrl>https://raw.githubusercontent.com/pester/pester/master/images/pester.PNG</iconUrl>
1212
<projectUrl>https://github.com/Pester/Pester</projectUrl>
1313
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
1414
</metadata>

publish/buildPSGalleryPackage.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ try {
1010
Copy-Item $baseDir\Pester.ps?1 $buildDir\
1111
Copy-Item $baseDir\LICENSE $buildDir\
1212
Copy-Item $baseDir\nunit_schema_2.5.xsd $buildDir\
13+
Copy-Item $baseDir\junit_schema_4.xsd $buildDir\
1314
Copy-Item $baseDir\bin $buildDir\ -Recurse
1415
Copy-Item $baseDir\Functions $buildDir\ -Recurse
1516
Copy-Item $baseDir\Dependencies $buildDir\ -Recurse

publish/publishPSGalleryPackage.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ try {
1717
& $psGet { [CmdletBinding()] param () Install-NuGetClientBinaries -CallerPSCmdlet $PSCmdlet -BootstrapNuGetExe -Force }
1818

1919
Write-Host 'Publishing module to PowerShellGet'
20-
$null = Publish-Module -Path $buildDir -NuGetApiKey $ApiKey -Confirm:$false
20+
$null = Publish-Module -Path $buildDir -NuGetApiKey $ApiKey -Confirm:$false -Force
2121
}
2222
catch {
2323
Write-Error -ErrorRecord $_

publish/release.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Copy-Item "$PSScriptRoot/../bin/*" $psGalleryDir -Recurse
4343

4444
$files = @(
4545
"nunit_schema_2.5.xsd"
46+
"junit_schema_4.xsd"
4647
"Pester.psd1"
4748
"Pester.psm1"
4849
"report.dtd"

publish/signModule.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ param($Thumbprint, $Path)
22
$ErrorActionPreference = 'Stop'
33

44
$cert = Get-ChildItem Cert:\CurrentUser\My |
5-
where Thumbprint -eq $Thumbprint
5+
Where-Object Thumbprint -eq $Thumbprint
66

77
if ($null -eq $cert) {
88
throw "No certificate was found."
@@ -29,7 +29,7 @@ if (-not @($filesToSign)) {
2929
}
3030

3131
$results = $filesToSign |
32-
ForEach-Object {
32+
ForEach-Object {
3333
$r = Set-AuthenticodeSignature $_ -Certificate $cert -TimestampServer 'http://timestamp.digicert.com' -ErrorAction Stop
3434
$r | Out-String | Write-Host
3535
$r

src/Pester.psd1

+4-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@
5151
'Get-ShouldOperator'
5252

5353
# export
54-
'Export-NunitReport'
54+
'Export-NUnitReport'
5555
'ConvertTo-NUnitReport'
56+
# 'Export-JUnitReport'
57+
# 'ConvertTo-JUnitReport'
5658
'ConvertTo-Pester4Result'
5759

5860
# legacy
@@ -103,7 +105,7 @@
103105
LicenseUri = "https://www.apache.org/licenses/LICENSE-2.0.html"
104106

105107
# Release notes for this particular version of the module
106-
ReleaseNotes = 'https://github.com/pester/Pester/blob/v5.0/README.md'
108+
ReleaseNotes = 'https://github.com/pester/Pester/releases/tag/5.0.0-rc6'
107109

108110
# Prerelease string of this module
109111
Prerelease = 'rc6'

src/Pester.psm1

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Set-Alias 'Get-AssertionOperator' 'Get-ShouldOperator'
3636
# export
3737
'Export-NunitReport'
3838
'ConvertTo-NUnitReport'
39+
# 'Export-JUnitReport' does not work yet, it needs similar rework as NUnit to work with the new structure
40+
# 'ConvertTo-JUnitReport'
3941
'ConvertTo-Pester4Result'
4042

4143
# legacy

src/en-US/about_Should.help.txt

+16
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ SHOULD MEMBERS
2525
$actual | Should -Be "actual value" # Test will pass
2626
$actual | Should -Be "not actual value" # Test will fail
2727

28+
Also compares an entire array for equality and throws if the array is not the same.
29+
30+
$array = @(1, 2, 3, 4, 'I am a string', (New-Object psobject -Property @{ IAm = 'An Object' }))
31+
$array | Should -Be $array # Test will pass
32+
33+
$string = 'I am a string'
34+
$array = @(1, 2, 3, 4, $string)
35+
$arrayWithCaps = @(1, 2, 3, 4, $string.ToUpper())
36+
$array | Should -Be $arrayWithCaps # Test will pass
37+
38+
Comparisons will fail if the arrays have the same values, but not the same order.
39+
40+
[int32[]]$array = (1..10)
41+
$arrayoutoforder = (1,10,2,3,4,5,6,7,8,9)
42+
$array | Should -Be $arrayOutOfOrder # Test will fail
43+
2844
BeExactly
2945
Compares one object with another for equality and throws if the two objects are not the same. This comparison is case sensitive.
3046

src/functions/Context.ps1

+19-8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Script that is executed. This may include setup specific to the context
2323
and one or more It blocks that validate the expected outcomes.
2424
2525
.EXAMPLE
26+
```ps
2627
function Add-Numbers($a, $b) {
2728
return $a + $b
2829
}
@@ -39,18 +40,28 @@ Describe "Add-Numbers" {
3940
It "..." { ... }
4041
}
4142
}
43+
```
4244
4345
.LINK
44-
https://github.com/pester/Pester/wiki/Context
46+
https://pester.dev/docs/commands/Describe
4547
4648
.LINK
47-
Describe
48-
It
49-
BeforeEach
50-
AfterEach
51-
about_Should
52-
about_Mocking
53-
about_TestDrive
49+
https://pester.dev/docs/commands/It
50+
51+
.LINK
52+
https://pester.dev/docs/commands/BeforeEach
53+
54+
.LINK
55+
https://pester.dev/docs/commands/AfterEach
56+
57+
.LINK
58+
https://pester.dev/docs/commands/Should
59+
60+
.LINK
61+
https://pester.dev/docs/usage/mocking
62+
63+
.LINK
64+
https://pester.dev/docs/usage/testdrive
5465
5566
#>
5667
param(

src/functions/Coverage.ps1

+2
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,8 @@ function Get-JaCoCoReportXml {
798798
nr = $line
799799
mi = $class.Lines.$line.Instruction.Missed
800800
ci = $class.Lines.$line.Instruction.Covered
801+
mb = 0
802+
cb = 0
801803
})
802804
}
803805

src/functions/Get-ShouldOperator.ps1

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ function Get-ShouldOperator {
2626
-Name is a dynamic parameter that tab completes all available options.
2727
2828
.LINK
29-
https://github.com/Pester/Pester
30-
about_Should
29+
https://pester.dev/docs/commands/Should
30+
3131
#>
3232
[CmdletBinding()]
3333
param ()
@@ -46,8 +46,8 @@ function Get-ShouldOperator {
4646
$AttributeCollection.Add($ParameterAttribute)
4747

4848
$arrSet = $AssertionOperators.Values |
49-
Select-Object -Property Name, Alias |
50-
ForEach-Object { $_.Name; $_.Alias }
49+
Select-Object -Property Name, Alias |
50+
ForEach-Object { $_.Name; $_.Alias }
5151

5252
$ValidateSetAttribute = & $SafeCommands['New-Object']System.Management.Automation.ValidateSetAttribute($arrSet)
5353

0 commit comments

Comments
 (0)