Question: 1. Create a Calculator.java class. Create following 4 static methods(with return type float): Add(), Subtract(), Multiply() and Divide() Each of the above methods should take
1. Create a Calculator.java class. Create following 4 static methods(with return type float): Add(), Subtract(), Multiply() and Divide() Each of the above methods should take two arguments and return the final result after the operation. 2. Create a test class now with a name CalculatorTest.java. In this class perform the following steps: Import the following libraries at the top of this file: import org.JUnit.Before; import org.JUnit.Test; import static org.JUnit.Assert.assertEquals; 3. Create the object of Calculator.java class by writing the following code in CalculatorTest.java class. privateCalculator calculator; @Before publicvoidsetUp() { this.calculator = newCalculator(); } 4. Now, generate the JUnit test classes for all the methods one by one. Declare and initialize the two variables to pass those to the 4 methods. Store the expected result in one of the variables and then compare it with the actual returned value of the specific function. 5. After creating 4 JUnit test cases for addition, subtraction, multiplication, and division, run all the test cases one by one. Check the output. All the test cases should be passed at the end.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
