chiefmyron / phpunit-test-workbench

An extension to integrate PHPUnit with the native Test Explorer functionality within VS Code. Zero configuration required for common environment setups.
https://marketplace.visualstudio.com/items?itemName=chiefmyron.phpunit-test-workbench
MIT License
5 stars 2 forks source link

Error peek not appearing on correct line when running Laravel v10.x tests #101

Closed chiefmyron closed 5 months ago

chiefmyron commented 5 months ago

I’m seeing [error peeks] show up on the wrong line though, I think because it’s using the last line of the stacktrace rather than the last line of code in my actual app:

SCR-20240506-iyhd

Originally posted by @macbookandrew in https://github.com/chiefmyron/phpunit-test-workbench/issues/98#issuecomment-2096211328

chiefmyron commented 5 months ago

Original response:

This looks like something specific to the 10.x release of Laravel, which is why I missed it. Essentially, the Illuminate\Foundation\Testing\TestCase class is extending the runTest() method of the base PHPUnit TestCase class, and so the failure is bubbled up through that class. This method is not extended in the v11.x branch, or v9.x and earlier branches - it is specific only to v10.x.

Will have to check the full set of items in the stack to associate the last message reported against the test class file, rather than relying on it always being the last item in the stack.

Fix is to check the full set of files in the error stack, and pick the line number from the last reported instance of the test class file. If the test class file does not appear at all in the error stack, default to showing the peek against the method definition.

macbookandrew commented 5 months ago

Awesome — thanks!!