-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Updated Pester Syntax in Writing Tests Guide #8039
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
Conversation
- Modified the Pester syntax for the `-Be` assertion (instead of just `Be`) to reflect the preferred use per latest version of Pester. - Added an example showing use of `-BeOfType` to test the type of a variable. - Other minor changes for grammar.
Update to WritingPesterTests.md
|
|
||
| #### Describe | ||
| Creates a logical group of tests. All Mocks and TestDrive contents defined within a Describe block are scoped to that Describe; they will no longer be present when the Describe block exits. A `Describe block may contain any number of Context and It blocks. | ||
| Creates a logical group of tests. All Mocks and TestDrive contents defined within a Describe block are scoped to that Describe; they will no longer be present when the Describe block exits. A Describe block may contain any number of Context and It blocks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be - A `Describe` block
|
|
||
| The DESCRIBE BeforeAll block is executed before any other code even though it was at the bottom of the Describe block, so if state is set elsewhere in the describe BLOCK, that state will not be visible (as the code will not yet been run). Notice, too, that the BEFOREALL block in Context is executed before any other code in that block. | ||
| Generally, you should have code reside in one of the code block elements of `[Before|After][All|Each]`, especially if those block rely on state set by free code elsewhere in the block. | ||
| The Describe BeforeAll block is executed before any other code even though it was at the bottom of the Describe block, so if state is set elsewhere in the describe BLOCK, that state will not be visible (as the code will not yet been run). Notice, too, that the BeforeAll block in Context is executed before any other code in that block. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`Describe` `BeforeAll`
BLOCK -> block
|
You also have spelling issues. I filed the following issue on the spelling tests: #8078 |
Co-Authored-By: markwragg <mark@wragg.io>
Co-Authored-By: markwragg <mark@wragg.io>
Co-Authored-By: markwragg <mark@wragg.io>
|
The PR is still failing the spelling check. FYI, I'm out of the office for the next week and will be checking GitHub less frequently. |
|
It's hard to tell from the spelling test output which specific words it's failing on, but to me it looks like in each case it's Pester domain-specific words like I'm pretty sure this PR has not introduced any new spelling mistakes, and I think it is an improvement on the previous version of this page, so my suggestion would be to merge it and iterate with further versions for other improvements. If you can provide more specifics on spellings that you want edited however I'm happy to implement. |
|
@markwragg Please replace ' with backstick. It'll resolve all issues. 'RequireAdminOnWindows' -> `RequireAdminOnWindows` |
JamesWTruher
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a couple things, but important (i think)
| It "1 is really an int" { | ||
| $i = 1 | ||
| $i.GetType() | Should Be "int" | ||
| $i.GetType() | Should -BeExactly "int" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should really be:
$i | Should -BeOfType [int]
and consistent with the next change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing this then makes this example a duplicate of the one that follows it. Should we just remove this example instead of we don't want to recommend checking types this way?
|
restarted macOS CI |
|
@markwragg Thanks for your contribution! |
PR Summary
-Beassertion (instead of justBe) to reflect the preferred use per latest version of Pester.-BeOfTypeto test the type of a variable.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests