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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started