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

  • Home
  • SEARCH
  • 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 3402252
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:06:54+00:00 2026-05-18T05:06:54+00:00

I am familiar with JUnit testing in android.. My Question is if we are

  • 0

I am familiar with JUnit testing in android..
My Question is if we are using calculator and we want to test addition operation..To test the addition operation if we are using more number of test cases(for example 30). instead of rewriting the test cases for 30 times, is there any generic way to do this or is there any way to take the test cases form excel sheet or xml file..?

Please let me know is there any better way …

Thanks in advace

  • 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-18T05:06:55+00:00Added an answer on May 18, 2026 at 5:06 am

    You could reduce duplicate code by making a function and calling it in each JUnit test. E.g.:

    public void test_add_zeroPlusZero()
    {
      Assert.assertTrue("Failed on 0+0.", testAdd(new int[] {0,0}),0);
    }
    
    private boolean testAdd(int[] values, int expectedValue)
    {
      // Try to add.
      // If adding fails, return false.
      // If adding succeeds, return true.
    }
    

    As for reading in huge numbers of test values, couldn’t you just read in multiple rows of integers (representing the values to add and the expected result, each value separated by a space or something) from file and then put them through the testAdd function (or equivalent) shown above? In pseudocode, this might look like:

    public void test_add_from_file()
      File testValueFile = get file with test values()
      while ((nextLine = testValueFile.readLine) != END_OF_FILE)
        int[] values = parse values from nextLine
        int expectedValue = parse expected value from nextLine
        Assert.assertTrue("Couldn't add the following values: " + values, testAdd(values, expectedValue))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am familiar with jUnit. What unit testing framework is very popular for VS?
I am familiar with nunit for unit testing of the business layer however I
Im familiar with accessing parent windows like this: window.parent.document.getElementById(ad_nr) But what if I want
A familiar problem using VisualStudio is the mysterious calling of property getters. If these
I am familiar using IPv4 broadcast of UDP packets as a technique for probing
I'm not familiar with the web services. I created a Email Service using web
I am getting familiar with Google Sites. What I want is, building a Site
I'm somewhat familiar with Cocoa, Objective-C and iPhone Development using Xcode. I'm starting to
I'm familiar with techniques used for testing controllers and business logic in ASP .NET
:) This question is for anyone familiar with the Tankauth plugin. I edited tankauth

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.