Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

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

Next Generation Databases NoSQLand Big Data

Authors: Guy Harrison

1st Edition

1484213300, 978-1484213308

More Books

Students also viewed these Databases questions

Question

What standards define related parties, and what is the definition?

Answered: 1 week ago

Question

What is the role of NWC in projects?

Answered: 1 week ago