Skip to content

Commit 9db6fc6

Browse files
committed
Created object first, then updated settings.
1 parent 8e61d26 commit 9db6fc6

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

Extension/PesterTask/PesterV10/Pester.ps1

+17-21
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,18 @@ if ($PSBoundParameters.ContainsKey('additionalModulePath')) {
8686
Write-Host "Adding additional module path [$additionalModulePath] to `$env:PSModulePath"
8787
$env:PSModulePath = $additionalModulePath + ';' + $env:PSModulePath
8888
}
89+
$PesterConfig = [PesterConfiguration]::Default
8990

90-
$PesterConfig = @{
91-
92-
Run = @{
93-
Path = $TestFolder
94-
PassThru = $true
95-
}
96-
TestResult = @{
97-
Enabled = $true
98-
OutputFormat = 'NUnit2.5'
99-
OutputPath = $resultsFile
100-
}
91+
$PesterConfig.run = @{
92+
Path = $TestFolder
93+
PassThru = $true
10194
}
95+
$PesterConfig.TestResult = @{
96+
Enabled = $true
97+
OutputFormat = 'NUnit2.5'
98+
OutputPath = $resultsFile
99+
}
100+
102101

103102
$Filter = @{}
104103
if ($Tag) {
@@ -110,30 +109,27 @@ if ($ExcludeTag) {
110109
$Filter.Add('ExcludeTag', $ExcludeTag)
111110
}
112111

113-
$PesterConfig['Filter'] = $Filter
112+
$PesterConfig.Filter = $Filter
114113

115-
$CodeCoverage = @{}
116114
if ($CodeCoverageOutputFile) {
117-
$CodeCoverage['Enabled'] = $True
118-
$CodeCoverage['OutputFormat'] = "JaCoCo"
115+
$PesterConfig.CodeCoverage.Enabled = $True
116+
$PesterConfig.CodeCoverage.OutputFormat = "JaCoCo"
119117

120118
if (-not $PSBoundParameters.ContainsKey('CodeCoverageFolder')) {
121119
$CodeCoverageFolder = $TestFolder
122120
}
123121
$Files = Get-ChildItem -Path $CodeCoverageFolder -include *.ps1, *.psm1 -Exclude *.Tests.ps1 -Recurse |
124-
Select-object -ExpandProperty Fullname
122+
Select-object -ExpandProperty Fullname
125123

126124
if ($Files) {
127-
$CodeCoverage.Add('Path', $Files)
128-
$CodeCoverage.Add('OutputPath', $CodeCoverageOutputFile)
125+
$PesterConfig.CodeCoverage.Path = $Files
126+
$PesterConfig.CodeCoverage.OutputPath = $CodeCoverageOutputFile
129127
}
130-
else {
128+
else {`
131129
Write-Warning -Message "No PowerShell files found under [$CodeCoverageFolder] to analyse for code coverage."
132130
}
133131
}
134132

135-
$PesterConfig['CodeCoverage'] = $CodeCoverage
136-
137133
if (-not([String]::IsNullOrWhiteSpace($ScriptBlock))) {
138134
$ScriptBlockObject = [ScriptBlock]::Create($ScriptBlock)
139135

0 commit comments

Comments
 (0)