Skip to content

Commit

Permalink
Add GIVEN WHEN THEN
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianCousin committed Dec 23, 2023
1 parent 6ac7e80 commit 07ff297
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ class RecursiveComparisonAssert_isEqualTo_java_objects_Test extends RecursiveCom
@Test
void should_describe_cause_of_equals_use() {

// GIVEN two equal values of a type from a java package
IntSummaryStatistics statisticsActual = new IntSummaryStatistics();
IntSummaryStatistics statisticsExpected = new IntSummaryStatistics();

// WHEN recursive comparison is called
ThrowableAssert.ThrowingCallable equalComparison = () -> assertThat(statisticsActual).usingRecursiveComparison()
.isEqualTo(statisticsExpected);
AssertionError assertionError = expectAssertionError(equalComparison);

// THEN additional information explains how was the comparison done
assertThat(assertionError.getMessage()).contains("Comparison objects are of Java types and were then compared with equals method");
}
}

0 comments on commit 07ff297

Please sign in to comment.