Question: Please answer questions using from the java code: a) Detailing what tests you performed and your rational behind your tests. b) Where your tests always
Please answer questions using from the java code:
a) Detailing what tests you performed and your rational behind your tests.
b) Where your tests always successful?
c) What determines a successful test?
d) Snapshot of test results for any failures and ultimately of all successes
upload of the entire source code included in this assignment with the ADDITION of conducting the two additional tests as commented in the source.
ArithmeticFunctions.java
public class ArithmeticFunctions { public int sub(int a, int b) { return a - b; }
public int mult(int a, int b) { return a * b; }
public int add(int a, int b) { return a + b; }
public double div(int a, int b) { if (b != 0) { System.out.println("b cannot be 0"); return 0.0; } else { return a / b; }
} }
ArithmeticTest.java
import junit.framework.TestCase;
public class ArithmeticTest extends TestCase { ArithmeticFunctions functions = new ArithmeticFunctions(); ArithmeticFunctions functions1; public void test() { assertEquals("Addition of 5 and 7 is 12", 12, functions.add(5, 7)); } public void testForSub() { assertEquals("Subtraction of 5 and 7 is 2", 2, functions.sub(5, 7)); } public void testForNull(){ assertNull("Null value found" , functions1); } //students: test again for null value given functions1.add() //students: create an assert to test for div by zero!
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
