PhpStorm 2020.1 Help

Navigate between test and test subject

In PhpStorm, you can quickly navigate between a test and the test subject.

For more information on common testing procedures, see Perform tests.

For language- and framework-specific guidelines, see Testing JavaScript, Testing Node.js PHPUnit, Behat, Codeception, PHPSpec , and Web Technologies.

Jump from a test to its test subject

  1. Open a test class in the editor.

  2. From the editor context menu, choose Go To | Test Subject or press Ctrl+Shift+T.

    The test subject for the current test class opens in the dedicated tab of the editor and gets the focus.

In the PHP context, when working with PHPUnit and Codeception tests, you can use the @covers annotation to maintain the link between the test class or method and their test subjects.

This way, it will be possible to navigate between the test and test subject even if their names do not follow the PHPUnit naming convention:

class Person { public function getAge() {} } /** @covers Person */ class TestForPersonClass extends TestCase { /** @covers Person::getAge */ public function testCorrectAgeIsReturned() {} }

Jump from a class, file, or method to its test

  1. Open a test class in the editor. If you want to navigate from the method to its test, position the caret at this method.

  2. If more than one test is associated with the test subject, select the desired one from the list. The test for the current class opens in the dedicated tab of the editor and gets the focus.

Last modified: 08 May 2020