Debugging info in module scope#183
Merged
dlwyatt merged 2 commits intopester:Betafrom Aug 7, 2014
Merged
Conversation
This causes failed tests to output the proper file and line from the tests.ps1 file, and also allows for setting breakpoints inside these blocks. There are two other places that currently use Set-ScriptBlockScope and may lose similar information: Mocks, and BeforeEach / AfterEach. I'm not sure we can do much about the latter, but we can possibly add this same type of change to the Mocking code, if needed.
For exceptions that are generated by something other than the Should command, test failure output now contains the file path and line number of whatever code produced the exception, instead of mixing the file path of the Tests.ps1 script and the line number from whatever file contained the error-producing code. May revisit this to either change it to report the path / line number of the Tests.ps1 file (as failed Should assertions currently do), or output both sets of information.
This file contains hidden or 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
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.
As @Jaykul pointed out in #180, file and line information output in failed tests is sometimes inaccurate. There were two problems that I know of in the Beta branch:
InModuleScopeblock, file information was completely lost, and line numbers were wrong.Shouldcommand, you'd wind up seeing a line number from wherever the exception came from, but a file path to the Tests.ps1 script.Both of these cases have been corrected, and failed test output should contain accurate information now.
As a nice perk, this also gets breakpoints working again for the parts of a test script contained within an
InModuleScopeblock. (The same condition which led to the loss of file information also made breakpoints based on script / line number not work for those lines.)