Question
Go to this link https://www.guru99.com/junit-tutorial.html to learn about the basics, download, and install JUnit. The instructor will walk you through some JUnit test cases. You
- Go to this link https://www.guru99.com/junit-tutorial.html to learn about the basics, download, and install JUnit.
- The instructor will walk you through some JUnit test cases.
- You will then be asked to write some test cases on your own.
- Here are the starter files.
Calculation.java
public class Calculation {
//TestLogicTest - Test it in TestLogicTest.java
public static int findMax(int arr[]){
int max=arr[0];
for(int i=1;i
}
return max;
}
//cube - create a method that returns cube of a long. Test it in
TestLogicTest.java
//reverse - create a method that returns the reverse of a string. Test it in
TestLogicTest.java
}
TestLogicTest.java
import org.junit.Assert;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.BeforeClass;
import org.junit.AfterClass;
public class TestLogicTest {
/** Fixture initialization (common initialization
* for all tests). **/
@BeforeClass
public static void setUp() throws Exception {
System.out.println("Before class");
}
@Test
public void testFindMax(){
assertEquals(4,Calculation.findMax(new int[]{1,3,4,2}));
assertEquals(-1,Calculation.findMax(new int[]{-12,-1,-3,-4,-2}));
}
@Test
public void testCube(){
//Test cube here
}
@Test
public void testReverse(){
//Test reverse here
}
@AfterClass
public static void exit() throws Exception {
System.out.println("After class");
}
}
5. Review the starter files given above. Read the Junit tutorial and complete the TestLogicTest test cases. Submit the Calculation.java code and TestLogicTest.java to Canvas.
Step by Step Solution
3.46 Rating (149 Votes )
There are 3 Steps involved in it
Step: 1
It seems like you want me to guide you through completing the test cases in the TestLogicTest class ...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