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
Add missing container-parameters to Data #1986
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nohwnd
reviewed
Jun 11, 2021
fflaten
changed the title
Use default value for undefined container parameters
Add missing container-parameters to Data
Jun 14, 2021
fflaten
commented
Jun 14, 2021
I think this is ready for review. Wondered if it should have some tests when using |
nohwnd
approved these changes
Jun 23, 2021
I am not sure how that should work either. 😬 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Summary
Pester containers may use parameters to support data-driven test generation.
This scenario currently has the following limitations:
Describe 'd1' -ForEach { myparam = $myparam}
. This makes debugging harder sinceDebug Tests
in VSCode doesn't allow the user to provide-Data ...
for the container (file).*All/*Each
setup-blocks placed outside any Describe/Context-blocks. TheDescribe -ForEach ..
-workaround above does not work for these root-scoped setup-blocks.New-PesterContainer ... -Data @{ MyAlias = 123 }
:$MyParam
would be 123 and$MyAlias
would not exist. This is default PowerShell-behavior.$MyParam
would not exist and$MyAlias
would be 123. This is because Pester adds uses the provided-Data
directly during Run.This PR adds logic to detect container-parameters not defined by the user at runtime and automatically adds them to Data for the Root-block of the container. New behavior:
$MyParam
(see example above) is also defined in Run like it is in Discovery to be more consistent and similar to normal PowerShell-function/script behavior.Fix #1980
PR Checklist
Create Pull Request
to mark it as a draft. PR can be markedReady for review
when it's ready.