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 7689195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:06:28+00:00 2026-05-31T20:06:28+00:00

are most of the JUnit test written for public methods or private methods? Which

  • 0

are most of the JUnit test written for public methods or private methods? Which do I need to focus on if I have not so much time?

  • 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-05-31T20:06:30+00:00Added an answer on May 31, 2026 at 8:06 pm

    You should to test everything that forms part of the API. Unless you’re using reflection, this means the public/protected and package level methods.

    Clearly, this is opinion. But it is one based on experience. Let me take my opinion further.

    Ideally, you should practice test-driven development. In this practice you:

    1. Write the tests first, including in them the public methods of the test subject that you wish to have. This helps you devise a useful API.
    2. Then you write just enough code to make the tests pass. This will leave you with 100% coverage and no extraneous code.
    3. Then you refactor.

    Until you get to the refactoring stage, you probably won’t even have any private methods.

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

Sidebar

Related Questions

I have the following test case in eclipse, using JUnit 4 which is refusing
Most of time we represent concepts which can never be less than 0. For
I found the discussion on Do you test private method informative. I have decided,
I have a simple test for maven plugin: public class SimpleMavenTest extends AbstractMojoTestCase {
I have a package with a single public facade , with two methods ,
I have imported a time series with dates of the following format: test =
Most of our Eclipse projects have multiple source folders, for example: src/main/java src/test/java When
I am trying to enable assertions (the keyword, not the junit methods) in my
I'm writing a Junit test in which the expected result is a XML string.
Most program languages have some kind of exception handling; some languages have return codes,

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.