Skip to content

Add support for passing a PesterConfiguration object to PowerShellBuild #83

@joshooaj

Description

@joshooaj

Currently PowerShellBuild accepts several options to control how Pester is invoked through the $PSBPreference variable. However, there are more Pester options available if you go the "advanced" route and pass in a [PesterConfiguration] object.

You can generate a configuration a few different ways...

$config = New-PesterConfiguration

$config = [PesterConfiguration]::Default

$config = [PesterConfiguration]::new()

We could support all Pester options in an easier way than implementing $PSBPreference settings for each of them individually by allowing users to provide their own Pester configuration like so...

# file: psakeFile.ps1
Properties {
    $PSBPreference.Test.Configuration = New-PesterConfiguration -Hashtable @{
        # Change defaults as needed. For example...
        Run = @{
            SkipRemainingOnFailure = 'Run'
        }
    }
}

There are some considerations though. For example, the advanced option allows providing multiple paths. Should PowerShellBuild be opinionated and aim to maintain the current test behavior by default? If PowerShellBuild overrides properties like Run.Path, should the user be allowed to change that? How so?

Maybe other values from $PSBPreference.Test should be used to override the user-supplied [PesterConfiguration] and if they want to override those defaults, they should do it by updating the corresponding $PSBPreference.Test.* property?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions