-
-
Notifications
You must be signed in to change notification settings - Fork 467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend and export New-PesterConfiguration #1728
Conversation
New attempt 😅 |
Will get back to this once I clean up some more stuff in the 5.1 milestone. I am trying to get it to releasable state soon. |
This is what I envision the api might look like in the future, but I just want to avoid conflicts for now, I am open to feedback of course: New-PesterConfiguration `
-Run (New-PesterRunConfiguration -Path $PSScriptRoot -PassThru) `
-CodeCoverage (New-PesterCodeCoverageConfiguration -Path $PSScriptRoot -OutputFormat "CoverageGutters") `
-HashTable @{} # some settings to be used as base, and amended by the settings above
-Default:$false # (maybe in future) do not inherit settings from profile?
-Configuration # (maybe in future) path to pester configuration in a file?
# maybe some templates as well? But how would this handle multiple templates, e.g. CI with code coverage,
# and are there other useful templates choices?
New-PesterConfiguration -Template CI |
Can you elaborate on the I guess my main question is: Do you see these functions as the primary method of configuration going forward? Considering how interactive the PesterConfiguration-object already is, will this compete or compliment it? I believe giving the users too many options can be confusing (+ more code + more documentation), so I thought this function had two possible directions:
|
-default $false. -> yes one possible syntax to ignore some default configuration, most likey the one inherited from pester preference. Maybe I am just overthinking this. I think the form where we have the separate functions is nicer, but it also means there would be quite a few, which probably does not matter. |
Not necessarily. I just couldn't think of any other default-kind of values except PesterPreference atm. I'd personally recommend a switch-parameter over bool every time to disable/ignore that. The second option can feel a bit verbose and maybe complex, especially for Should and Output which currently only has one option each, but at least it won't explode with hundred parameters (and aliases) over time while providing intellisense and early input-validation. $container = New-PesterContainer -ScriptBlock { param($first) ... } -Data @{ first = "1st" }
$run = New-PesterRunConfiguration -Path $PSScriptRoot -Container $container -PassThru
$output = New-PesterOutputConfiguration -Verbosity 'Detailed'
$conf = New-PesterConfiguration -Run $run -Output $output -Template CI -IgnoreDefaults
Invoke-Pester -Configuration $conf Users familiar with the options can use hashtable (or another serialized file in the future) to keep their scripts short either wway. And there's always the Simple-interface of For now, should I update according to review comments so this PR can go forward as a start (only default and hashtable-conversion as options)? Or put this on hold until there's more input on the end-game from the #1265 ? I'd like more discussion before extending with 8 |
Believe it or not I actually meant -Default to be a switch, I forgot to put |
Nice and clean. |
1. General summary of the pull request
Extends and exports a wrapper-function for creating
[PesterConfiguration]
objects used to runInvoke-Pester
with advanced configurations. Binary classes like this aren't available until a module is imported, which may cause errors for users who depend on auto-loading as creating the configuration object is normally the first step before any call toInvoke-Pester
or any other public functions.Using this wrapper, a user will always be able to create a configuration-object as the first action (which triggers the auto-loading of Pester). The function is kept simple and has few parameters to avoid confusion for the user as the
[PesterConfiguration]
is intuitive, self-explanatory and might change over time.Fix #1674
Replaces #1683