Question: JAVA ONLY You will be creating a JUnit Test Class for Gradebook . java (provided). Gradebook has two attributes: an array of int called scores

JAVA ONLY

JAVA ONLY You will be creating a JUnit Test Class for Gradebook. java (provided). Gradebook has two attributes: an array of int calledscores to hold scores and scoresize that indicates how many scores are

You will be creating a JUnit Test Class for Gradebook . java (provided). Gradebook has two attributes: an array of int called scores to hold scores and scoresize that indicates how many scores are currently held in the array. This field is initially set to 0 . Task \#1: 1. Add a getScoreSize() method to the Gradebook class which returns scoresSize; 2. Add a toString() method to the Gradebook class that returns a string with each score in scores field of the Gradebook separated by a space. Task \#2: Create the Test Class GradebookTester by right clicking on the GradeBook.java, select New, Junit Test Case. Using the wizard: 1. Select the setUp and tearDown method check boxes and click Next. 2. Select all of the methods of Gradebook, except for the constructor to create tests for. Then click finish. Task \#3: 1. In the setUp method of GradebookTester, create at least two objects of Gradebook to hold 5 scores. Then call the addscore method for each of the Gradebook objects at least twice (but no more than 5 times) to add some random scores of your choice to the GradeBook objects 2. In the teardown method of GradebookTester, set the two objects of Gradebook to null. 'ask \#4: Create test for the methods of Gradebook: 1. addScore - Use the toString method to compare the contents of what is in the scores array vs. what is expected to be in the scores array assertirue( (..) - Compare the scoresize to the expected number of scores entered, using asserttguals(...) 2. sum - Compare what is returned by sum() to the expected sum of the scores entered. 3. minimum - Compare what is returned by minimum() to the expected minimum of the scores entered. 4. finalscore - Compare what is returned by finalscore() to the expected finalscore of the scores entered. The finalScore is the sum of the scores, with the lowest score dropped if there are at least two scores, or 0 if there are no scores. Example: As a private attribute (member) of GradeBookTest: GradeBook gl; In setup: g1 = new GradeBook (5); g1.addScore (50); g 1.addScore(75); In teardown: g1=null; in testSum(: assertequals (125, g1.sum(), .0001); in testMinimum(): assertEquals (50, 91.minimum (), .001); in addScoreTest(); assertTrue(g1.tostring().equals("50.075.0")

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!