Closed joeypiccola closed 4 years ago
I would disagree that this is a 'Bug Fix' and would suggest it's a potential 'Breaking Change'. For those that import the module anyway in their tests it's unlikely to affect them. However, for those who work on the assumption that the module is not imported during the tests, this is potentially a build breaker.
I personally would prefer to see this change being turned off by default and it can be turned on if needed.
Just my 2p worth.
This latest commit is what I was thinking based on the discussion on Issue #45. The issue I see now is that this does not work if someone uses the PSBPreference.Build.ModuleOurDir
. 🤔
@joeypiccola Is this because of the ModuleOutputManifest
parameter? I'm struggling to understand why that's needed when it could simply be calculated (or can it not be)?
@pauby You're right, it can be calculated. It took me a bit to understand what Initialize-PSBuild
was doing and that it changes BHBuildOutput
. You can now see I'm leveraging this calculated value in Test-PSBuildPester
.
Edit: I just corrected my above statement as I still had a misunderstanding with what Initialize-PSBuild
was doing. I think I got it now 🤦 .
Are there any additional thoughts or questions on this PR? Thanks, everyone!
@joeypiccola This looks good. Thanks!
I tested locally by adding a new Pester test to the TestModule
module. When adding an InModuleScope
test that validates the output of the private function, it works when setting $PSBPreference.Test.ImportModule
to $true
and fails when $false
as expected.
Description
This PR adds the property
ImportModule
to thetest
build property hash. This property is passed toTest-PSBuildPester
so that Pester can optionally import the module from the specified OutDir. This feature can be optionally used by specifying$PSBPreference.Test.ImportModule = $true
.Related Issue
45
Motivation and Context
Optionally import module prior to running Pesters tests.
.tests.ps1
files removing redundant code to import the project module.OurDir
.How Has This Been Tested?
PowerShellBuild/0.5.0
directory.v0.2.0
psakeFile.ps1
file to usetask Test -FromModule PowerShellBuild -Version '0.5.0'
.build.ps1 -bootstrap
build.ps1 -task pester
Types of changes
Checklist:
Fixes #45