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
You could reduce duplicate code by making a function and calling it in each JUnit test. E.g.:
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: