Intellij Idea "Move refactoring" with Junit tests

intellij-idea, junit

Solution

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.

Problem

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?

Original source