Linking Unit Tests to their corresponding class

Hi there,

just wanted to ask whether there is a smart solution for adding some kind of annotation that links a class to its corresponding unit test and vice versa. What I'm doing at the moment is this:

/**
 * Some class which has a unit test in
 *
 * @see SomeClassTest
 */
class SomeClass {

     /* ... */
}


and within my test, I'm doing something like this:

/**
 * Some test class
 *
 * @see SomeClass
 *
class SomeClassTest {

     /* ... */
}


So I can jump from the class to its test with CTRL+Click.

What I would like to have is some more semantic information within my annotations, e.g.

/**
 * Some class which has a unit test in
 *
 * @attachedTest SomeClassTest
 */
class SomeClass {

     /* ... */
}


and within my test, I'm doing something like this:

/**
 * Some test class
 *
 * @correspondingClass SomeClass
 */
class SomeClassTest {

     /* ... */
}




Is there any possibility to add my own annotations and give them some functionality / constraints - e.g. "word after annotation must be class name"


Thanks a lot!

Regards

Mimi

3 comments
Comment actions Permalink

Hi Michael,

Use Navigate | Test to jump between test class and tested class. If it does not work for you -- then look into naming conventions or similar -- works perfectly fine here.

0
Comment actions Permalink

Hi Andriy,

thanks for your response. This solves "half my issue". Jumping from Test to Implementation and vice-versa is possible now. But another thing I want to do is using a tag for showing which test-class belongs to my implementation and the other way round. Is it possible to define custom tags or annotations?

Thanks a lot

Mimi

0
Comment actions Permalink

I do not know why do you need this extra tag when navigation works already .. plus if you follow the unit test naming convention, it should be obvious which test-class belongs to which implementation. But you can either use already mentioned @see tag ... or use your own tag -- unknown tag will simply be ignored (when displaying quick documentation, for example) or, at very least, will not be processed in any special way (for example PHPUnit uses custom tags that have meaning only for PHPUnit); you cannot define custom tag or annotation in PhpStorm that will enforce specific format or content (e.g. has to be only class name after the tag)..

0

Please sign in to leave a comment.