- Test java.util.PriorityQueue class with Junit
- import java.util.PriorityQueue;
- Parameterization
- Testcase : { random array } , { correct array }.
- Random array specifies your own input array.
- Correct array means the PriorityQueue polling correct order instead of using toArray().
- Please Create 5 unique testcases.
- Exception
- There are 3 unique Exceptions thrown by PriorityQueue.
- IllegalArgumentException
whenExceptionThrown_thenInitialCapacityNotGreaterThanOne()
- NullPointerException
whenExceptionThrown_thenOfferEisNull()
- ClassCastException
whenExceptionThrown_thenCastWrongType()
- Success case :
-
Exception exception = assertThrows(ClassCastException.class, () -> { PriorityQueue pq = new PriorityQueue(); pq.add(0); pq.add('0'); });
-
- Failure case :
-
Exception exception = assertThrows(ClassCastException.class, () -> { PriorityQueue pq = new PriorityQueue(); pq.add(0); pq.add(0); });
-
- IllegalArgumentException
- There are 3 unique Exceptions thrown by PriorityQueue.
irisowo / st-2022-0616086 Goto Github PK
View Code? Open in Web Editor NEWLab_3 submission of software-testing, NYCU