PhpUnit - going into test method for failed tests

For tests we have 2 methods to go "Jump to source" and "Show source". Unfortunately if tests fails when I choose any of them I get the same code - the place in whole application where the test is failing but any of them doesn't go into this particular test code. For example when I use Laravel framework, I will go into some Laravel methods that fail, but I cannot jump to source of test class where this test is written, so unfortunately I need to manually navigate to the class/method. Is there any way to do it automatically?



When the test fails, "Jump to Source" sends me to that test method which failed.

If you press "Show source" first and then "Jump to source", does it place the caret at the right position?


Hi again

Thank you for reply.

First thing - could you please explain me difference between "Show source" first and then "Jump to source"? Both seems to work same in all cases.

And about issue - it depends on test I run.

For example when I run functional test and my test method looks like this:

 /** @test */
public function activate_with_invalid_email()
['email' => '', 'activation_token' => 'token']);
$this->verifyErrorResponse(404, ErrorCode::USER_NOT_FOUND);


and test fails, I would like to go directly to this method (or to the exact line that causes error - in this case into last line.

However both "Show source" and "Jump to source"  goes into Laravel framework method:

protected function seeStatusCode($status)
$this->assertEquals($status, $this->response->getStatusCode());

return $this;

I know that finally this method causes that assertion fails, but it doesn't help if I need to go manually into my Test class and find method activate_with_invalid_email to fix the test.Now I'm going into internal Laravel test class that calls PhpUnit assertion.

I hope now you get the issue.



In my case "Jump to Source" just opens (jumps to) the right PHPUnit test class file, but is placing the caret NEITHER to the line with the failing test case NOR the line with the failing assertion.


If you're using 2018.1 EAP build: try the Main menu | Navigate | Test shortcut (ctrl+shift+T on Windows). Should work both for test classes and test methods


@Dimitry: Thanks for the fast response. It sounds like this navigation shortcut is for editor from test subject class/code to test class/code, the problem I was referring to is, however, in running tests view (see screenshot below): ideally a double click on the failing test case should jump to either the source code of the failing test case method or line with the failing assertion. (Somehow I have the feeling this used to work, or am I mixing this up with IntelliJ?)

The "jump to source" or "Show source" are only the second best choice with respect to comfort, but they also do not jump to the test case.


Thanks a lot @Dimitry: yes, with PhpStorm 2018.1 it works as expected (again?) => it correctly jumps to the test case method definition


Please sign in to leave a comment.