Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: FEST-Assert 1.3
-
Fix Version/s: FEST-Assert 1.4
-
Component/s: Assert
-
Labels:None
-
Number of attachments :
Description
From Ansgar:
The following code will yield an AssertionError:
List<Integer> myList = Arrays.asList(1, 2, 3);
Iterator i = myList.iterator();
assertThat(i).isNotNull();
assertThat(i.hasNext()).isTrue();
Reason: assertThat() consumes the iterator. Should probably be done as late as possible, i. e. inside isNotEmpty().
This might lead (did in our project) to failing tests when switching from FEST-Assert 1.2 to 1.3 (as 1.2 did not have assertThat(Iterator<?>) and assertThat(Iterator<?>), so the Java compiler resolved assertThat
to assertThat(Object) and the second assertion still succeeded).