Junit test cases of non public class

I have a class as following

package a.b
public class Public_Class{
  public void add(){
    //logic
  }
}
class Non_Public_Class{
  public void subt(){
    //any logic
  }
}
package a.c

Now I want to make test cases of method subt() in "Non_Public_Class".

How can I access that non public class and my test cases are not in the same package?

Jon Skeet
people
quotationmark

How can I access that non public class and my test cases are not in the same package.

Change that, basically. It's pretty common practice (at least as far as I've seen) to keep your production and test classes in separate source hierarchies, but still put them into the same Java packages - precisely so you can then test package-access classes easily.

(I'd definitely still split them into different source hierarchies, that output to different class directories, too, so that you don't need to package your test code with your production code.)

people

See more on this question at Stackoverflow