Question
I am trying to implement some assert methods into a test method but I am not sure on how to do that. We are currently
I am trying to implement some assert methods into a test method but I am not sure on how to do that. We are currently in the subject of Junit testing. This method has to pass the test with no failures or errors. Thank you!
here is my current code.
public void testCreateIterator() { System.out.println("createIterator"); StudentCollectionSpec instance = StudentCollection.createStudentCollection(); Iterator
---------------------------------------
Here is what it needs
Rule / requirement being tested Set up work required test value | Expected result(must be verified via appropriate Junit assert..() invocations)
createIterator() | creates an Iterator object that allows the entire contents of the collection to be retrieved, one element at a time; Iterator.remove() is not supported | create four student objects, SIDs in the sequence first, smallest, largest, last; create a reference collection of size 4 and insert all four students; create a checklist collection (array,ArrayList,List,whatever) of size 4 and insert all four students;
invoke createIterator via the REFERENCE collection
| n/a | returned handle non-null; loop through the iterator object: student = handle.next(); increment counter; remove student from the checklist collection (if student not removed, test fails) end loop; referenceCollection.getStudentCount() == counter; checklistCollection.isEmpty() == TRUE; handle.hasNext() == false; handle.next() throws NoSuchElementException |
| " | create collection of size four | n/a | returned handle non-null; handle.hasNext() == false handle.next() throws NoSuchElementException |
| " | create collection of size 5; create three student objects S1, S2, S3, with unique SIDs in ascending non-consecutive sequence, adding each to the collection | n/a | returned handle non-null; handle.remove() throws UnsupportedOperationException
|
| " | create collection of size 5 | n/a | returned handle non-null; handle.remove() throws UnsupportedOperationException |
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