The problem is that I use Mockito for testing a class with some protected methods. In order to mock them I need my tests to be in the same package. I'm using the following scheme now:
project
---src
------some.package.for.class
---------MyClass.java
---tests //source folder
------some.package.for.class //so test package looks the same
---------Tests.java
It works, but the problem is that I don't trylly understand how. As I understand, BuildPath is part of Eclipse IDE, which help Eclipse to find files and libraries for my project. So how is it possible to keep tests in other folder but in the same package???
And another question: is it possible to keep java files in one packages, yet in different projects?
Is it possible to have class files in the same package but in different folders? Yes.
Is it possible to have class files in the same package but in different projects? Yes.
When the classes load, they can come from many different places, including different JARs, but still be in the same package.
Regarding Eclipse, you just need to make sure you've selected all the source folders (including tests) in Java Build Path > Source. There is no restriction that says all class files in the same package must be in the same folder.