Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can eclipse automatically rename the unit test class when the class under test is renamed?

Tags:

java

eclipse

I often use the refactor -> rename functionality in eclipse and I also have the habit of naming the associated unit test TestedClassNameTest. But when I rename my tested class I must not forget to rename my unitTest. It would be extremely useful to rename my unit test automatically when the tested class is renamed.

I guess it wouldn't be that difficult to create a plugin that does the job but maybe that isn't even necessary?

like image 281
Stijn Vanpoucke Avatar asked Jul 23 '10 11:07

Stijn Vanpoucke


2 Answers

I've found a plugin that does the trick http://moreunit.sourceforge.net/

like image 97
Stijn Vanpoucke Avatar answered Oct 16 '22 04:10

Stijn Vanpoucke


After several googling and eclipse searches, it seems such feature is not yet available.

Today there is no notion of "class being unit tested" in Eclipse. What I mean here, is that you can create a Unit test classes testing anything you want: a full package, a single class, a single method, a full plugin ....

To get more accurate, there is "NO relation in Eclipse's model" between your tested class and the associated unit test.

I totally agree with you that it would be nice to such a feature in Eclipse. To go further it would be really cool to be able to generate Unit tests skeletons and thus have these tests classes linked to the tested ones.

May be you can laucnh the discussion on Eclipse Buzilla, maybe in the PDE category.

Manu

like image 35
Manuel Selva Avatar answered Oct 16 '22 03:10

Manuel Selva