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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:24:59+00:00 2026-05-26T22:24:59+00:00

I am a totally noob in writing jUnit tests. I have an Android program

  • 0

I am a totally noob in writing jUnit tests. I have an Android program and have to write tests for it. I know how to and i wrote tests with robotium, but now i need functional tests and i don’t where to start. I have one function from my code:

private void onCoordinatesUpdate(Location loc){
    List<Event> list = wc.requestEvents(loc.getLatitude(), loc.getLongitude());
    if(list != null){
        adapter = new EventsArrayAdapter(this.getApplicationContext(), R.id.eventsView, (ArrayList<Event>)list);
        ev.setAdapter(adapter);
    }
}

I have to write test for for it. The thing which makes problem for me, is that i have no idea how to write test, which would detect if expression in IF sentence is changed for example from “list != null” to “list == null”. The only idea of test which i can think of is this:

public void testCheckInternet(){
    assertTrue(mClassToTest.checkInternet());
}

But his test only checks if device is connected to internet and that’s it. I don’t need anybody to write test for me, but maybe somebody could at lest show me the way 🙂 how to start 🙂 thanks in advance.

  • 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-26T22:25:00+00:00Added an answer on May 26, 2026 at 10:25 pm

    The method you provided is private and as a consequence is hard to test with JUnit. When doing unit testing with JUnit you should only test public methods. The private methods will be tested indirectly.
    If there are private methods in your classes which you would like to test explicitly you should rethink your class design. One solution would be to extract this private method into a new class and make the method public.

    Generally speaking there is code which is testable and there is code which is not. Test driven development is a technique which helps to design testable code. A good starting point is the JUnit documentation.

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

Sidebar

Related Questions

Ok. very much totally noob question but I really don't have a clue and
i'm totally noob to asp.net mvc and currently i'm writing an web app which
I need to make an installer for a MySQL 5.1 Database, but I'm totally
Sorry for question, but I'm totally noob in Java. What is the best practice
So, i'm a total noob with codeigniter but i'm getting by. I have a
Totally revising this question, since I fixed the first issue but have ran into
I am a totally noob at CakePHP and have been dealing with this site
am totally new to Javascript , but i need it for using googlemaps in
Totally stupid question, but I'm writing my first ASP.NET C# web forms application and
Totally confused here. I have a PARENT UIViewController that needs to pass an NSMutableArray

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.