Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

It seems like you want me to guide you through completing the test cases in the TestLogicTest class ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Auditing Cases An Interactive Learning Approach

Authors: Steven M Glover, Douglas F Prawitt

4th Edition

0132423502, 978-0132423502

More Books

Students also viewed these Programming questions

Question

Show that the variance of the linear combination

Answered: 1 week ago