Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7812351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:28:35+00:00 2026-06-02T04:28:35+00:00

I have a package with a single public facade , with two methods ,

  • 0

I have a package with a single public facade , with two methods , start and stop.
Because this facade is for something like a 50+ internal/friendly classes package , I need a way to be able and test several of those inner classes directly.

I am using Eclipse and JUnit.

Reflection can be a good way , but why writing all this reflection code on my own , is there a good tool that generates wrapper public classes (like .net visual studio can ) ?

Second of all , can someone please explain how to manage a dual source tree for JUnit or refer me to a good article in that topic ?
I saw several blog posts but prefer to see if someone from here has a good explanation/reference.

and , most important — either or not to test internal classes , is not my question here , this is my design and this is how I prefer to work .
Some think you should , some think you should not , so please dont post answers such as : you should test only public thus problem solved.
I searched in stackoverflow and could not find a good thread about it.

Thank you in advance ,

James .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:28:36+00:00Added an answer on June 2, 2026 at 4:28 am

    Your instinct to maintain a dual source tree is correct. Simply have two source directories, with the same directory/package structure within. Compile to similarly separate output destinations, but put everything in your classpath when you run tests. Even though the classes may be even different output directories, their identical directory/package structure will make it work. If you use Maven, this is standard. With that tool, the source directory names are src/main and src/test, and the output directories are target/classes and target/test-classes. The fact that Maven supports this out of the box shows how standard this practice is within the Java community and you should use it with confidence. (For that matter, I encourage you to use Maven, it will make your life a lot easier. You can use Maven with Eclipse and lots of people do.)

    With unit tests now being inside your package, you can test all the package-protected classes you want. I disagree with people who say only test public things. In fact, no less a luminary than Cedric Beust, the author of TestNG, argues that if it can break, it should be tested, and that includes private methods. I have unit tested private methods with a little help from reflection. Package-protected stuff is of course easier to test. Regardless, I think it’s a religious argument to say that only public things should be tested.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's Say I Have This Class: package{ import flash.display.Sprite; public class Main extends Sprite{
I have a package with logic classes(like CheckAuthenticationDataLogic.java, GetVocabulariesLogic.java). And another class - ApiService.java
I have one package contains many Stored Procedure for populating diffrent tables. This package
I have an SSIS Package with two steps: 1) FTP in to a server
I have a Util package with source files in three seperate directories, defined like
I am missing something obvious, but I'm not sure what. I have a single
I am missing something obvious, but I'm not sure what. I have a single
I have a package with a few modules, each module has a class (or
I have next package structure webService.ear -- dependency.jar -- some.class Can I remove some.class
My current requirement is: I have to package my grails app and use teamcity

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.