Skip to content

Commit 73b06ec

Browse files
refactor(tests): 🔧 Update test setup to use build script (#171)
* Replaced `Set-BuildEnvironment` with a call to the build script in multiple test files. * This change standardizes the test environment setup across all test cases. * Allows easier testing with the Testing VS Code tool. ## What this changes Ensures that a build is run before a Pester test run. This help when invoking directly with Pester or via the VS Code Test tool. ## Why <!-- The motivation. Link to the issue this fixes or the discussion that prompted it. --> Closes # ## Type of change - [ ] Bug fix (non-breaking change that corrects incorrect behavior) - [ ] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that changes existing behavior) - [x] Chore / refactor / documentation (no behavior change) ## Checklist - [x] Pester tests added or updated to cover the change - [ ] `Invoke-psake Analyze` passes locally with no new warnings - [ ] `Invoke-psake Test` passes locally on at least one platform - [ ] `CHANGELOG.md` updated (required for any user-facing change) - [ ] Documentation updated if behavior changed ## Additional notes <!-- Anything reviewers should know: edge cases, known limitations, follow-up work, testing instructions. -->
1 parent b53eecc commit 73b06ec

14 files changed

Lines changed: 14 additions & 14 deletions

‎Tests/Chocolatey.Type.Tests.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ BeforeDiscovery {
77

88
BeforeAll {
99
if (-not $env:BHProjectPath) {
10-
Set-BuildEnvironment -Path "$PSScriptRoot/.." -Force
10+
& "$PSScriptRoot\..\build.ps1" -Task 'Build'
1111
}
1212
Remove-Module $env:BHProjectName -ErrorAction SilentlyContinue
1313
Import-Module (Join-Path $env:BHProjectPath $env:BHProjectName) -Force

‎Tests/Command.Type.Tests.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
BeforeAll {
44
if (-not $env:BHProjectPath) {
5-
Set-BuildEnvironment -Path "$PSScriptRoot/.." -Force
5+
& "$PSScriptRoot\..\build.ps1" -Task 'Build'
66
}
77
Remove-Module $env:BHProjectName -ErrorAction SilentlyContinue
88
Import-Module (Join-Path $env:BHProjectPath $env:BHProjectName) -Force

‎Tests/DotnetSdk.Type.Tests.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
BeforeAll {
44
if (-not $env:BHProjectPath) {
5-
Set-BuildEnvironment -Path "$PSScriptRoot/.." -Force
5+
& "$PSScriptRoot\..\build.ps1" -Task 'Build'
66
}
77
Remove-Module $env:BHProjectName -ErrorAction SilentlyContinue
88
Import-Module (Join-Path $env:BHProjectPath $env:BHProjectName) -Force

‎Tests/FileDownload.Type.Tests.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ BeforeDiscovery {
77

88
BeforeAll {
99
if (-not $env:BHProjectPath) {
10-
Set-BuildEnvironment -Path "$PSScriptRoot/.." -Force
10+
& "$PSScriptRoot\..\build.ps1" -Task 'Build'
1111
}
1212
Remove-Module $env:BHProjectName -ErrorAction SilentlyContinue
1313
Import-Module (Join-Path $env:BHProjectPath $env:BHProjectName) -Force

‎Tests/FileSystem.Type.Tests.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ BeforeDiscovery {
77

88
BeforeAll {
99
if (-not $env:BHProjectPath) {
10-
Set-BuildEnvironment -Path "$PSScriptRoot/.." -Force
10+
& "$PSScriptRoot\..\build.ps1" -Task 'Build'
1111
}
1212
Remove-Module $env:BHProjectName -ErrorAction SilentlyContinue
1313
Import-Module (Join-Path $env:BHProjectPath $env:BHProjectName) -Force

‎Tests/Git.Type.Tests.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
BeforeAll {
44
if (-not $env:BHProjectPath) {
5-
Set-BuildEnvironment -Path "$PSScriptRoot/.." -Force
5+
& "$PSScriptRoot\..\build.ps1" -Task 'Build'
66
}
77
Remove-Module $env:BHProjectName -ErrorAction SilentlyContinue
88
Import-Module (Join-Path $env:BHProjectPath $env:BHProjectName) -Force

‎Tests/GitHub.Type.Tests.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
BeforeAll {
44
if (-not $env:BHProjectPath) {
5-
Set-BuildEnvironment -Path "$PSScriptRoot/.." -Force
5+
& "$PSScriptRoot\..\build.ps1" -Task 'Build'
66
}
77
Remove-Module $env:BHProjectName -ErrorAction SilentlyContinue
88
Import-Module (Join-Path $env:BHProjectPath $env:BHProjectName) -Force

‎Tests/Noop.Type.Tests.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
BeforeAll {
44
if (-not $env:BHProjectPath) {
5-
Set-BuildEnvironment -Path "$PSScriptRoot/.." -Force
5+
& "$PSScriptRoot\..\build.ps1" -Task 'Build'
66
}
77
Remove-Module $env:BHProjectName -ErrorAction SilentlyContinue
88
Import-Module (Join-Path $env:BHProjectPath $env:BHProjectName) -Force

‎Tests/Npm.Type.Tests.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
BeforeAll {
44
if (-not $env:BHProjectPath) {
5-
Set-BuildEnvironment -Path "$PSScriptRoot/.." -Force
5+
& "$PSScriptRoot\..\build.ps1" -Task 'Build'
66
}
77
Remove-Module $env:BHProjectName -ErrorAction SilentlyContinue
88
Import-Module (Join-Path $env:BHProjectPath $env:BHProjectName) -Force

‎Tests/Nuget.Type.Tests.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
BeforeAll {
44
if (-not $env:BHProjectPath) {
5-
Set-BuildEnvironment -Path "$PSScriptRoot/.." -Force
5+
& "$PSScriptRoot\..\build.ps1" -Task 'Build'
66
}
77
Remove-Module $env:BHProjectName -ErrorAction SilentlyContinue
88
Import-Module (Join-Path $env:BHProjectPath $env:BHProjectName) -Force

0 commit comments

Comments
 (0)