Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i would like some asistance, new to the software design i have an assignment due which involves junit coding: please help with the test class

i would like some asistance, new to the software design i have an assignment due which involves junit coding: please help with the test class and assoicated junit code. thank you!

Unit being tested

Rule / requirement being tested

Setup work required

Test value

Expected result(s) (all must be verified via appropriate JUnit assert() invocations

createStudentCollection()

none default-sized collection

none

n/a

returned handle non-null; getCapacity() == DEFAULT COLLECTION_CAPACITY; isEmpty() == TRUE; isFull() == FALSE; getStudentCount() == 0;

getRemainingSpaces() == DEFAULT COLLECTION_CAPACITY

createStudentCollection(int)

collection size > 0

none

-1

StudentCollectionException thrown

"

"

0

StudentCollectionException thrown

"

"

1

non-null handle returned; getCapacity() == 1; isEmpty() == TRUE; isFull() == FALSE; getStudentCount() == 0; getRemainingSpaces() ==1

getCapacity()

returns storage capacity

getSpacesRemaining()

returns number of available storage spaces

reset()

sets collection to an empty state

isFull()

determines if there is any remaining storage capacity

isEmpty()

determines if the collection is empty

getStudentCount()

returns number of elements in collection

addStudent()

inserts a student object into the collection

create collection of size 4; create student1 with a known SID value (SID1) (note replace "SID1" with a valid value during actual testing)

student1 instance

no exception thrown; getStudentCount() == 1;

isEmpty() == false; isFull== false; getSpacesRemaining() == 3; retrieveStudentBySID(student1.getSID()) retrieves non-null handle and handle.getSID() == student1.getSID()

"

using same collection, create student2 with SID2 (different from SID1)

student2 instance

no exception thrown; getStudentCount() == 2;

isEmpty() == false; isFull() == false; getSpacesRemaining() == 2; retrieveStudentBySID(student2.getSID()) retrieves non-null handle and handle.getSID() == student2.getSID(); retrieveStudentBySID(student2.getSID()) retrieves non-null handle and handle.getSID() == student1.getSID() ("paranoia check")

"

using same collection, create student3 with SID3 (different from SID1 and SID2)

student SID3 instance

no exception thrown; getStudentCount() == 3;

isEmpty() == false; isFull() == true; getSpacesRemaining() == 1; retrieveStudentBySID(student3.getSID()) retrieves non-null handle and handle.getSID() == student3.getSID()

Here are the test classes in which need to be created

package studentcollection; import java.util.Iterator; import java.util.NoSuchElementException; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import static org.junit.Assert.*; import student.Student; import studentspec.StudentSpec; import studentcollection.StudentCollectionSpec.StudentCollectionException; public class StudentCollectionTest { public StudentCollectionTest() { } @BeforeClass public static void setUpClass() { } @AfterClass public static void tearDownClass() { } @Before public void setUp() { } @After public void tearDown() { } /** * Test of getCapacity method, of class StudentCollection. */ @Test public void testGetCapacity() { System.out.println("getCapacity"); } /** * Test of reset method, of class StudentCollection. */ @Test public void testReset() { } /** * Test of isFull method, of class StudentCollection. */ @Test public void testIsFull() { System.out.println("isFull"); } /** * Test of isEmpty method, of class StudentCollection. */ @Test public void testIsEmpty() { System.out.println("isEmpty"); } /** * Test of getStudentCount method, of class StudentCollection. */ @Test public void testGetStudentCount() { System.out.println("getStudentCount"); } /** * Test of addStudent method, of class StudentCollection. */ @Test public void testAddStudent() { System.out.println("addStudent"); } /** * Test of retrieveStudentBySID method, of class StudentCollection. */ @Test public void testRetrieveStudentBySID() { System.out.println("retrieveStudentBySID"); } /** * Test of removeStudentBySID method, of class StudentCollection. */ @Test public void testRemoveStudentBySID() { System.out.println("removeStudentBySID"); } /** * Test of toString method, of class StudentCollection. */ @Test public void testToString() { System.out.println("toString"); } /** * Test of createIterator method, of class StudentCollection. */ @Test public void testCreateIterator() { System.out.println("createIterator"); } /** * Test of getSpacesRemaining method, of class StudentCollection. */ @Test public void testGetSpacesRemaining() { System.out.println("getSpacesRemaining"); } /** * Test of writeCollectionToDisk method, of class StudentCollection. */ @Test public void testWriteCollectionToDisk() { System.out.println("writeCollectionToDisk"); } /** * Test of fileExists method, of class StudentCollection. */ @Test public void testFileExists() { System.out.println("fileExists"); } /** * Test of retrieveCollectionFromDisk method, of class StudentCollection. */ @Test public void testRetrieveCollectionFromDisk() { System.out.println("retrieveCollectionFromDisk"); } }

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

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions