fix: resolve test runner scoping issue
see https://github.com/pester/Pester/issues/2386
This commit is contained in:
parent
76ea9527b1
commit
956186c654
7 changed files with 8 additions and 21 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') -Force
|
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') -Force
|
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ $ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') -Force
|
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') -Force
|
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') -Force
|
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1')
|
||||||
|
|
||||||
$mockHost = 'confluence.contoso.com'
|
$mockHost = 'confluence.contoso.com'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') -Force
|
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1')
|
||||||
}
|
}
|
||||||
|
|
||||||
Describe 'Get-StringHash' `
|
Describe 'Get-StringHash' `
|
||||||
|
|
|
||||||
15
README.md
15
README.md
|
|
@ -104,20 +104,7 @@ You can execute the following from within a PowerShell session.
|
||||||
|
|
||||||
``PS> Invoke-Pester PSConfluencePublisher/*.Tests.ps1 -Show 'All'``
|
``PS> Invoke-Pester PSConfluencePublisher/*.Tests.ps1 -Show 'All'``
|
||||||
|
|
||||||
However the test suite still requires optimization towards execution, as Pester
|
or the following, from within a POSIX shell and PowerShell Core being present:
|
||||||
requires a certain setup for tests of nested modules to work. The `Force` switch
|
|
||||||
does not work as expected on the `Import-Module` cmdlet (within the `BeforeAll`
|
|
||||||
script blocks). Therefore it is advised to wrap the `Invoke-Pester` as follows
|
|
||||||
so that the global scope gets teared down after execution.
|
|
||||||
|
|
||||||
|
|
||||||
``$ pwsh -c "Invoke-Pester PSConfluencePublisher/*.Tests.ps1 -Show 'All'"``
|
``$ pwsh -c "Invoke-Pester PSConfluencePublisher/*.Tests.ps1 -Show 'All'"``
|
||||||
|
|
||||||
There currently is an issue with the invocation of the test suites (see
|
|
||||||
[Pester Issue #2386](https://github.com/pester/Pester/issues/2386)), where
|
|
||||||
some tests fail, if ran via the wildcard discovery.
|
|
||||||
|
|
||||||
Execute the following from within a PowerShell session to temporarily circumvent
|
|
||||||
this problem:
|
|
||||||
|
|
||||||
``$ pwsh -c 'Get-ChildItem PSConfluencePublisher/*.Tests.ps1 | ForEach {pwsh -c Invoke-Pester (Resolve-Path -Relative $_)}'``
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue