Buggy code:
public static Test suite ( ) { } public static void main ( String [ ] args ) { } private ArrayList < Integer > list = null ; private ArrayList < Integer > odds = null ; private ArrayList < Integer > evens = null ; private ArrayList < Integer > threes = null ; private ArrayList < Integer > fours = null ; private ArrayList < Integer > sixes = null ; private Predicate < Integer > truePred = null ; private Predicate < Integer > falsePred = null ; private Predicate < Integer > evenPred = null ; private Predicate < Integer > oddPred = null ; private Predicate < Integer > threePred = null ; private Predicate < Integer > fourPred = null ; private Random random = new Random ( ) ; public void setUp ( ) { } public void tearDown ( ) throws Exception { } public void testWalkLists ( ) { } public void testManual ( ) { } public void testTruePredicate ( ) { } public void testFalsePredicate ( ) { } public void testEvens ( ) { } public void testOdds ( ) { } public void testThrees ( ) { } public void testFours ( ) { } public void testNestedSixes ( ) { } public void testNestedSixes2 ( ) { } public void testNestedSixes3 ( ) { } public void testNextChangesPrevious ( ) { } public void testPreviousChangesNext ( ) { } public void testFailingHasNextBug ( ) { } private void walkForward ( ListIterator < ? > expected , ListIterator < ? > testing ) { } private void walkBackward ( ListIterator < ? > expected , ListIterator < ? > testing ) { } private void nextNextPrevious ( ListIterator < ? > expected , ListIterator < ? > testing ) { } private void previousPreviousNext ( ListIterator < ? > expected , ListIterator < ? > testing ) { } private < E > void walkLists ( List < E > list , ListIterator < E > testing ) { ListIterator < E > expected = list . listIterator ( ) ; walkForward ( expected , testing ) ; walkBackward ( expected , testing ) ; while ( expected . hasNext ( ) ) { assertEquals ( expected . nextIndex ( ) , testing . nextIndex ( ) ) ; assertEquals ( expected . previousIndex ( ) , testing . previousIndex ( ) ) ; assertTrue ( testing . hasNext ( ) ) ; assertEquals ( expected . next ( ) , testing . next ( ) ) ; assertTrue ( testing . hasPrevious ( ) ) ; assertEquals ( expected . previous ( ) , testing . previous ( ) ) ; assertTrue ( testing . hasNext ( ) ) ; assertEquals ( expected . next ( ) , testing . next ( ) ) ; } walkBackward ( expected , testing ) ; for ( int i = 0 ; i < ( list . size ( ) ) ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { assertEquals ( expected . nextIndex ( ) , testing . nextIndex ( ) ) ; assertEquals ( expected . previousIndex ( ) , testing . previousIndex ( ) ) ; assertTrue ( expected . hasNext ( ) ) ; assertTrue ( testing . hasNext ( ) ) ; assertEquals ( expected . next ( ) , testing . next ( ) ) ; } for ( int j = 0 ; j < ( i // 2 ) ; j ++ ) { assertEquals ( expected . nextIndex ( ) , testing . nextIndex ( ) ) ; assertEquals ( expected . previousIndex ( ) , testing . previousIndex ( ) ) ; assertTrue ( expected . hasPrevious ( ) ) ; assertTrue ( testing . hasPrevious ( ) ) ; assertEquals ( expected . previous ( ) , testing . previous ( ) ) ; } for ( int j = 0 ; j < ( i // 2 ) ; j ++ ) { assertEquals ( expected . nextIndex ( ) , testing . nextIndex ( ) ) ; assertEquals ( expected . previousIndex ( ) , testing . previousIndex ( ) ) ; assertTrue ( expected . hasNext ( ) ) ; assertTrue ( testing . hasNext ( ) ) ; assertEquals ( expected . next ( ) , testing . next ( ) ) ; } for ( int j = 0 ; j < i ; j ++ ) { assertEquals ( expected . nextIndex ( ) , testing . nextIndex ( ) ) ; assertEquals ( expected . previousIndex ( ) , testing . previousIndex ( ) ) ; assertTrue ( expected . hasPrevious ( ) ) ; assertTrue ( testing . hasPrevious ( ) ) ; assertEquals ( expected . previous ( ) , testing . previous ( ) ) ; } } <START_BUG> StringBuffer walkdescr = new StringBuffer ( 500 ) ; <END_BUG> for ( int i = 0 ; i < 500 ; i ++ ) { if ( random . nextBoolean ( ) ) { walkdescr . append ( "+" ) ; if ( expected . hasNext ( ) ) { assertEquals ( walkdescr . toString ( ) , expected . next ( ) , testing . next ( ) ) ; } } else { walkdescr . append ( "-" ) ; if ( expected . hasPrevious ( ) ) { assertEquals ( walkdescr . toString ( ) , expected . previous ( ) , testing . previous ( ) ) ; } } assertEquals ( walkdescr . toString ( ) , expected . nextIndex ( ) , testing . nextIndex ( ) ) ; assertEquals ( walkdescr . toString ( ) , expected . previousIndex ( ) , testing . previousIndex ( ) ) ; } } }

Fix:
StringBuilder walkdescr = new StringBuilder ( 500 ) ;