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

    1. Go to this link https://www.guru99.com/junit-tutorial.html to learn about the basics, download, and install JUnit.
    2. The instructor will walk you through some JUnit test cases.
    3. You will then be asked to write some test cases on your own.
    4. 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;iif(maxmax=arr[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

1 Expert Approved Answer
Step: 1 Unlock

It seems like you want me to guide you through completing the test cases in the TestLogicTest class ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!