For example, how do I test:
ArrayList<String> list = new ArrayList<String>();
list.iterator();
How to test this "iterator()
" method?
Thanks.
The few tests I can think of are:
You can also have a look at the tests used in openJDK.
You don't.
Guys from oracle and sun have already done that.
If you create your own implementation of iterator then you have to implement AFAIR 2 methods and you have to check if they obey to the contract.
Now that means: returning next element of underlying collection or throwing an exception and telling if there are subsequent elements. Just call those methods on your iterator and assert the result.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With