Skip to content

Commit da21f74

Browse files
koenpuntrstoyanchev
authored andcommitted
Print actual elements in GraphQlTester
See gh-507
1 parent f3d07c1 commit da21f74

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/DefaultGraphQlTester.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,9 +563,11 @@ public EntityList<E> doesNotContain(E... values) {
563563
public EntityList<E> containsExactly(E... values) {
564564
doAssert(() -> {
565565
List<E> expected = Arrays.asList(values);
566+
List<E> actual = getEntity();
566567
AssertionErrors.assertTrue(
567-
"List at path '" + getPath() + "' should have contained exactly " + expected,
568-
getEntity().equals(expected));
568+
"List at path '" + getPath() + "' should have contained exactly " + expected + ", " +
569+
"but did contain " + actual,
570+
actual.equals(expected));
569571
});
570572
return this;
571573
}

spring-graphql-test/src/test/java/org/springframework/graphql/test/tester/GraphQlTesterTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ void entityList() {
179179

180180
assertThatThrownBy(() -> entityList.containsExactly(leia, han))
181181
.as("Should be exactly the same order")
182-
.hasMessageStartingWith("List at path 'me.friends' should have contained exactly");
182+
.hasMessageStartingWith("List at path 'me.friends' should have contained exactly")
183+
.hasMessageContaining("but did contain ");
183184

184185
response.path("me.friends")
185186
.entityList(new ParameterizedTypeReference<MovieCharacter>() {})

0 commit comments

Comments
 (0)