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
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
Step: 1
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