java - How to JUnit test a iterator -
for example, how test:
arraylist<string> list = new arraylist<string>(); list.iterator();
how test "iterator()
" method?
thanks.
the few tests can think of are:
test hasnext on empty collection (returns false) test next() on empty collection (throws exception) test hasnext on collection 1 item (returns true, several times) test hasnext/next on collection 1 item: hasnext returns true, next returns item, hasnext returns false, twice test remove on collection: check size 0 after test remove again: exception final test collection several items, create sure iterator goes through each item, in right order (if there one) remove elements collection: collection emptyyou can have @ the tests used in openjdk.
java unit-testing testing junit
No comments:
Post a Comment