Question
Can someone help me fill in these jUnit Test cases and explain them too please? Unit being tested Rule / requirement being tested Setup work
Can someone help me fill in these jUnit Test cases and explain them too please?
Unit being tested | Rule / requirement being tested | Setup work required | Test value | Expected result(s) (all must be verified via appropriate JUnit assert() invocations |
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 |
|
|
|
|
|
|
|
|
retrieveStudentBySID() | retrieves a student from collection based on supplied SID value |
|
|
|
|
|
|
|
|
|
|
|
|
|
removeStudentBySID() | removes a student from collection based on supplied SID value |
|
|
|
|
|
|
|
|
|
|
|
| |
toString() | "stringifies" each collection element and concatenates the results into a single string | create a collection of size 4 | n/a | returned string == "empty collection" |
| " | create a collection of size 4, create two student objects S1 and S2, adding each to the collection | n/a | returned string == S1 + "&" + S2 |
writeCollectionToDisk() | write contents of collection to a specified file such that the contents can be read back at a later date | NOTE: it is not possible to verify writeCollectionToDisk() without invoking readCollectionFromDisk(), because without reading back what was written, there is no empirical evidence that what was written was written correctly. Similarly, readCollectionFromDisk() cannot be verified without first invoking writeCollectionToDisk(), because one must first write something to disk before it can be read. |
|
|
| filename cannot be null | none | null | throws IllegalArgumentException |
| filename cannot be an empty string | none | (empty string) | throws IllegalArgumentException |
| write contents of collection to a specified file such that the contents can be read back at a later date | create two students with different SIDs; create a reference collection (size 5) and a checklist collection (size 5); store the both students into both collections; invoke writeCollectionToDisk via the REFERENCE collection | valid filename | no exception thrown; fileExists(filename) == TRUE; create a retrieved collection (size 10); invoke retrieveCollectionFromDisk() via the RETRIEVED collection, no thrown exception; create an iterator via the RETRIEVED collection; loop through the iterator object: student = handle.next(); remove student from the checklist collection (if student is removed, increment count) end loop; referenceCollection.getStudentCount() == retrievedCollection.getStudentCount(); checkListCollection.getStudentCount() == 0; count = retrievedCollection.getStudentCount(); |
readCollectionFromDisk() | read contents of a collection that was previously written to disk | NOTE: it is not possible to verify readCollectionFromDis() without invoking writeCollectionToDisk(), because one must first write something to disk before it can be read. Similarly, readCollectionFromDisk() cannot be verified without first invoking writeCollectionToDisk(), because without reading back what was written there is no empirical evidence that what was written was written correctly and retrieved correctly. |
|
|
| filename cannot be null | none | null | throws IllegalArgumentException |
| filename cannot be an empty string | none | (empty string) | throws IllegalArgumentException |
| filename must exist | none | valid filename that does not exist | throws StudentCollectionException |
| filename exists but does not contain serialized content | create a file with non-serialized content (e.g. .docx, .pdf, .jpg) | valid filename | throws StudentCollectionException |
| filename exists but contains serialized content of a different class | Create a file with serialized content from any class other than StudentCollection | valid filename | throws StudentCollectionException |
| filename exists, contains serialized content of this class, but SVUID is different | Create a file with serialized content from a StudentCollection class version with a SVUID that differs from the current SVUID | valid filename | throws StudentCollectionException |
| write contents of collection to a specified file such that the contents can be read back at a later date | create two students with different SIDs; create a reference collection (size 5) and a checklist collection (size 5); store the both students into both collections; invoke writeCollectionToDisk via the REFERENCE collection | valid filename | no exception thrown; fileExists(filename) == TRUE; create a retrieved collection (size 10); invoke retrieveCollectionFromDisk() via the RETRIEVED collection, no thrown exception; create an iterator via the RETRIEVED collection; loop through the iterator object: student = handle.next(); remove student from the checklist collection (if student is removed, increment count) end loop; referenceCollection.getStudentCount() == retrievedCollection.getStudentCount(); checkListCollection.getStudentCount() == 0; count = retrievedCollection.getStudentCount(); |
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