Skip to content

Debugging info in module scope#183

Merged
dlwyatt merged 2 commits intopester:Betafrom
dlwyatt:DebuggingInfoInModuleScope
Aug 7, 2014
Merged

Debugging info in module scope#183
dlwyatt merged 2 commits intopester:Betafrom
dlwyatt:DebuggingInfoInModuleScope

Conversation

@dlwyatt
Copy link
Copy Markdown
Member

@dlwyatt dlwyatt commented Aug 7, 2014

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:

  • When tests execute inside an InModuleScope block, file information was completely lost, and line numbers were wrong.
  • When exceptions were thrown from something other than the Should command, 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 InModuleScope block. (The same condition which led to the loss of file information also made breakpoints based on script / line number not work for those lines.)

dlwyatt added 2 commits August 6, 2014 07:24
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.
dlwyatt added a commit that referenced this pull request Aug 7, 2014
@dlwyatt dlwyatt merged commit c4a638c into pester:Beta Aug 7, 2014
@dlwyatt dlwyatt deleted the DebuggingInfoInModuleScope branch August 7, 2014 11:58
@dlwyatt dlwyatt restored the DebuggingInfoInModuleScope branch August 11, 2014 01:58
@dlwyatt dlwyatt deleted the DebuggingInfoInModuleScope branch August 11, 2014 02:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant