Seems when I make "move" refactoring all my junit tests lays on its old place. Often I tests "package" visible classes, so they becomes invisible, if SUT moves to another package.
Do you move tests by hand?
Seems when I make "move" refactoring all my junit tests lays on its old place. Often I tests "package" visible classes, so they becomes invisible, if SUT moves to another package.
Do you move tests by hand?
The behaviour you describe is perfectly normal.
src/package1/A.java
test/package1/ATest.java
In your ATest.java
there's an import package1.A;
.
After your refactored, it looks like this:
src/package2/A.java
test/package1/ATest.java
The test code stayed where he was. You did not moved the test code, but your source code. It should not affect any other folders (like in your example).
The reference in the ATest.java
must now be import package2.A;
. Otherwise, the refactoring went wrong.
Nontheless, your tests should work, even if they are in a different directory. That's because the import was changed by the refactoring method.
If you want to clean up your folder structure, you have to manually rename the package test/package1
to test/package2
(I know, the package is package1
and package2
but I want to strengthen the focus on the folder structure.
I hope I could help you!
I have 4 options for you:
Go to the "Package" view in the left, select both files, and then hit F6. It should move them both to the right place.
Make the class public temporarily, before you do your refactor, and switch back afterwards.
Try moving the test first. I seem to remember that avoids breaking any of the dependencies.
There is a plugin (I think it's toggleTest or unitTest-- I had both of them installed) that patches the Move Refactor to also bring the test with it. Worked great. Unfortunately it looks like these may not work with the latest IDEA.