Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to refactor test code together with production code?

Suppose you start with an auto-generated method

public void setKey(Key key) {
    this.key = key;
}

And write a test for it

@Test
public void testSetKey() 

Then 3 month from now you decide that a more appropriate name for the method would be changeKeyTo. You refactor your production code and end up with:

public void changeKeyTo(Key key) {
    this.key = key;
}

Life is good, however, your test name remained unchanged

@Test
public void testSetKey() 

How do you deal with something like this? Can you refactor test code automatically with your production code? Does eclipse allow this?

like image 697
James Raitsev Avatar asked Nov 13 '22 08:11

James Raitsev


1 Answers

eclipse would not figure this out to change: It only changes the references of the method used in other classes or in the same class.
If you really want to make this functionality work, you could extend eclipse's refactoring API as I did for my project and give it this new functionality.
If you like to have any references on this just ask me ;-)

like image 162
GingerHead Avatar answered Nov 16 '22 03:11

GingerHead