Community
Participate
Working Groups
Form the news group I am trying to change the setUp method in my test suite so that it performs some standard behaviour and delegates to a new method, uiSetUp. I have my own abstract superclass for the tests: UITestCase. I want to change existing subclasses (about 35 of them) from overriding setUp to overriding uiSetUp. Likewise for tearDown. For example, the old code is: public abstract class UITestCase extends TestCase { // setUp is not overridden from JUnit's TestCase class } public class ConcreteUITestCase extends UITestCase { protected void setUp() { // do some test-specific setup (most implementations don't currently call super) } } The new way should be: public abstract class UITestCase extends TestCase { protected final void setUp() { // do some standard setup, common to all tests, which can't be overridden) uiSetUp(); } protected void uiSetUp() { // do nothing by default } } public class ConcreteUITestCase extends UITestCase { public void uiSetUp() { // do some test-specific setup } } I tried simply renaming setUp to uiSetUp in UITestCase, but it won't let me do that without starting at the highest declaration of setUp in TestCase. Can any of the existing refactorings help with this change? Thanks, Nick
Unfortunatelly not. The rename refactoring is semantic preserving. So if you rename setup it renames all methods in the hierarchy with the same signature and all references to them. The refactoring you are requesting is something like: "convert method into template method and create delegate with existing signature". I will open a feature request.
We have now rename method and keep delegate. I guess the refactoring could allow the rename of all method in source (and keep the one in binary), if you choose not to rename all references.