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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:20:32+00:00 2026-05-26T04:20:32+00:00

Sometimes I would like to test an intermediate value in a method. But the

  • 0

Sometimes I would like to test an intermediate value in a method. But the method can’t be split. So I wonder if JUnit can only test a method as a unit. If I can put something like a breakpoint in a method, and get the local value and assert it, it will be better. If it is impossible, how do you solve this kind of problem.

  • 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-26T04:20:33+00:00Added an answer on May 26, 2026 at 4:20 am

    Adding a break point is not really unit testing and in fact not testing at all. You can call it checking but there is no such thing as Check Driven Development.

    Anyhow, people new to Unit testing quite often find this issue that they want to test private or local values let that be a variable or method. When I started TDD I was in fact quite phased by it myself. But the thing is, in Unit testing the purpose is to do black box testing of a particular functionality and all possible outcomes from that. What happens inside that black box is not your concern nor do you need to unit test it.

    If you feel like testing an intermediate value then maybe your method is too long and should be split into two or more testable small methods. And if it can not be done then you should not be worrying about testing them.

    If that intermediate value is getting its value from another public method then it’s that method that you want to test in separate unit test, not the value inside the method you are currently testing.

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

Sidebar

Related Questions

Sometimes i would like to search for text containing a new line character and
We are sometimes getting an OutOfMemoryError in production and I would like to be
I would like to repeatedly execute a subprocess as fast as possible. However, sometimes
I would like to parse log files, I need to get only last IP
I was recently working on a windows program that would sometimes become unresponsive when
In my program, I'm grep-ing via NSTask. For some reason, sometimes I would get
Sometimes when I'm writing XLANG/s code in an expression shape, it would be more
How would you to convert or cast a List<T> to EntityCollection<T> ? Sometimes this
I sometimes need to debug JS in other browsers, and it would be really
By default, I think my vimrc setttings enable the auto-wrapping. However, sometimes, I would

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.