Question: import static org.junit.jupiter.api.Assertions.*; import java.io.*; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder;

import static org.junit.jupiter.api.Assertions.*;

import java.io.*; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays;

import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder;

@TestMethodOrder(MethodOrderer.OrderAnnotation.class) public class AnalyticsTest { public static double score = 0; public static String result = ""; public static String currentMethodName = null; public static ArrayList methodsPassed = new ArrayList(); Analytics aP, aCR, aD, aHD, aEmpty; @BeforeEach public void setUp() throws Exception { currentMethodName = null; aP = new Analytics(new int[][]{{30, 10, 40}, {50, 20, 80}, {10, 60, 30}, {60, 60, 60}}); aCR = new Analytics(new int[][]{{-30, 10, -40}, {-50, 20, 0}, {-10, 60, 30}, {-60, 60, 60}, {-20, -20, -20}});

aD = new Analytics(new int[][]{{-30, 10, -40}, {}, {-10, 60}, {-60}, {-20, -20, -20, -20, -20}, {-20, -20, -20, -20, -20}, {-20, -20, -20, -20, -20}, {-20, -20, -20, -20, -20}, {-20, -20, -20, -20, -20}, {-20, -20, -20, -20, -20}, {-20, -20, -20, -20, -20}});

aHD = new Analytics(new int[][]{{-30, 10, -40}, {}, {-10, 60}, {-60}, {-20, -20, -20, -20, -20}, {-20, -20}, {-20}, {}, {50}, {10, 30, 20}}); /** * note that i WILL add a couple more sets of test data in the actual marking: * * FOR EXAMPLE: * * aLong = new Analytics(new int[][]{{10,20,30,40,50,60,70,80,90,100,110,120,130}, * {-10,-20,-30,-40,-50,-60,-70,-80,-90,-100,-110,-120,-130}}); * * Thus (in this example), anyone who coded for at most 5 items in any sub-array will fail * the additional test. Make sure you program for arbitrary-sized data sets. */ aEmpty = new Analytics(new int[][] {}); }

@Test @Order(1) @Graded(description="testSizeP", marks=2.5) public void testSizeP() { assertEquals(4, aP.size()); currentMethodName = new Throwable().getStackTrace()[0].getMethodName(); } @Test @Order(2) @Graded(description="testSizeCR", marks=2.5) public void testSizeCR() { testSizeP(); assertEquals(4, aP.size()); assertEquals(5, aCR.size()); currentMethodName = new Throwable().getStackTrace()[0].getMethodName(); } @Test @Order(3) @Graded(description="testSizeD", marks=2.5) public void testSizeD() { testSizeCR(); assertEquals(4, aP.size()); assertEquals(5, aCR.size()); assertEquals(11, aD.size()); assertEquals(0, aEmpty.size()); currentMethodName = new Throwable().getStackTrace()[0].getMethodName(); } @Test @Order(4) @Graded(description="testSizeHD", marks=2.5) public void testSizeHD() { testSizeD(); assertEquals(4, aP.size()); assertEquals(5, aCR.size()); assertEquals(11, aD.size()); assertEquals(0, aEmpty.size()); assertEquals(10, aHD.size()); currentMethodName = new Throwable().getStackTrace()[0].getMethodName(); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!