-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Allow combining assertion failures into one #19
Comments
Some more concepts, probably the syntax with |
@nohwnd I think I've got a pattern that might work for simultaneous reporting of failed assertions in this usage, but without needing I'd rather not duplicate your work so I'm wondering if you've already got a solution for that. |
Here's a gist of the chaining pattern I was thinking of. If each Describe 'chained asserts' {
It 'fails some of these' {
24 |
Assert-Something {-not ($_ % 3)} 'divisible by 3' |
Assert-Something {-not ($_ % 4)} 'divisible by 4' |
Assert-Something {-not ($_ % 5)} 'divisible by 5' |
Assert-Something { $_ -gt 30 } 'greater than 30' |
Assert-Something { $_ -ge 0 } 'not negative'
}
} outputs |
That's pretty clever, propagating the value throught the pipeline and failing the last assertion first. Problem is that the assertions are collecting input in the process block, and then asserting on it in the end block. Is there any way we could use this? |
You're right about this technique not working for exceptions in the |
The first assertion to fail will fail the whole test. This leaves you with partial infomation, about why your test failed. Have a test containing these assertions:
Your test initally fails with "StatusCode is '400' but expected '200'.". You fix the call in
Get-WebRequest
and try again. Your test now fails with "Content is "abc" but expected 'Hello'".Multiply this by tens of tests that change failure messages as you progress fixing your code, and you have to work very hard to understand what you need to do to fix your code.
Compare that with this failure message:
This message contains all the failure messages combined, and tells you all the things that are wrong with your code. This allows for simpler overview of failures and easier development.
It is also extremely useful on build servers where you want to collect as much information about the failure as you can, to avoid fixing the code over multiple builds which can take many minutes to finish.
The text was updated successfully, but these errors were encountered: