How to Navigate Between Test and Test Subject using more descriptive Function Names
When using generated Codeception Unit Tests, in PHPStorm the default naming convention is testFunctionName(), and then one can navigate between the Test and Test subject using Ctrl + Shift + T as documented here ( https://www.jetbrains.com/help/phpstorm/navigating-between-test-and-test-subject.html )
However, i would like to create tests with more descriptive names i.e. testFunctionName_ReturnsTrue(), but when the test name doesn't match the function name PHPStorm can't jump to the code correctly (It just jumps to the namespaced unit).
I'm wondering if there is some method, i.e. use something like a @see PHPDoc hint that would allow me to provide some form of pointer to the actual function name/location?
i.e.
/**
* @see namespacedunit::functionName()
*/
public function testFunctionName_ReturnsTrue() {
$this->assertTrue(functionName());
}
Please sign in to leave a comment.
Please use "@covers \NS\Class" notation.
Does the @covers notation support full namespacing? The PHPDoc docs have a warning about @covers here...
http://docs.phpdoc.org/guides/types.html
But PHPUnit docs don't necessarily say anything about namespacing...
https://phpunit.readthedocs.io/en/8.0/annotations.html#covers
Fortunately i don't have any class name conflicts (yet), so namespacing isn't an issue currently, but would be nice if it does support it, as no doubt down the track i'll run into some conflicts sooner or later.
Have actually just had a play around with it, and the @covers declaration requires the fully qualified namespaced class::function notation.
i.e.
* @covers \TLS\JN\Constants::getFISTSuffix()
Which navigates to the correct function (i.e. puts the cursor in the right place in the Constants file).
Where as,
* @covers Constants::getFISTSuffix()
Only puts the cursor at the top of the Class in the Constants file.
So still potentially workable using the @covers notation.