Errors reported from Describe and Context blocks#168
Conversation
|
Quick note: I don't think this PR will be merged as-is. I just put it up as a starting point for us to discuss in issue 79's thread. Expect more commits to be added here as we figure out what the behavior should be. |
Quick update to make terminating errors that occur in a Describe or Context block cause a failed "test" to appear in the output. Because we're just piggybacking onto the existing PesterState.AddTestResult and Write-PesterResult code, the output looks as though it came from an It statement, though the name is always "Error occurred in Context block" or "Error occurred in Describe block". If this style of output is undesirable, a more extensive code update would be required.
This is along the same lines as the original commit in this branch, but addresses issue pester#91. Also moved the calls to Add-SetupAndTeardown into the Try blocks of Describe and Context.
Whitespace-only change
|
This branch produces failed tests when a test script contains a syntax error, or when terminating errors are produced from inside |
Errors reported from Describe and Context blocks
|
In addition to issue 79, this also takes care of #91. |
It's funny you should mention that - the error I was thinking about when I commented earlier was actually a nonterminating error and I'd forgotten to set $ErrorActionPreference in my test script. I wonder if it would make sense to add $ErrorActionPreference = 'Stop' and maybe a strict mode setting to the top of the generated fixtures and/or the examples in the Wiki. |
Quick update to make terminating errors that occur in a
DescribeorContextblock cause a failed "test" to appear in the output.Because we're just piggybacking onto the existing
PesterState.AddTestResultandWrite-PesterResultcode, the output looks as though it came from an It statement, though the name is always "Error occurred in Context block" or "Error occurred in Describe block". If this style of output is undesirable, a more extensive code update would be required.Do we need to handle nonterminating errors in this fashion as well, or leave that up to the person writing the test script? (For instance, they can set
-ErrorAction Stop, if they like.)This is intended to fix issue #79