Question: b) [3 marks] Given the following code , write the results: public static int add(int first, int second) { return firstNumber + secondNumber; } And
| b) [3 marks] Given the following code , write the results: public static int add(int first, int second) { return firstNumber + secondNumber; } And |
The test code:
@Before
public void setUp() {
math = new Math();
System.out.println("@Before - setUp");
}
@Test
public void add_TwoPlusTwo_ReturnsFour() {
final int expected = 4;
final int actual = math.add(2, 2);
Assert.assertEquals(actual, expected);
System.out.println("Test 1");
}
@Test
public void add_TwoPlusfour_ReturnssSix() {
final int expected = 6;
final int actual = math.add(2, 4);
Assert.assertEquals(actual, expected);
System.out.println("Test2");
}
@After
public void tearDown() {
math = null;
System.out.println("@After - tearDown");
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
