Skip to content

Commit

Permalink
Use AssertJ for better exception message
Browse files Browse the repository at this point in the history
TestNG's `assertEquals` does not cite collection contents when actual
and expected have different size.
  • Loading branch information
findepi committed Sep 18, 2020
1 parent f71c223 commit b378f1f
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
import java.util.ArrayList;
import java.util.List;

import static com.google.common.base.Verify.verify;
import static com.google.common.collect.Iterables.getOnlyElement;
import static java.lang.String.format;
import static java.lang.String.join;
import static java.util.Collections.unmodifiableList;
import static java.util.stream.Collectors.toList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.Assert.assertEquals;

public class DataTypeTest
Expand Down Expand Up @@ -122,9 +124,9 @@ private String buildPrestoQueryWithWhereClauses(TestTable testTable)

private void checkResults(List<Type> expectedTypes, List<Object> expectedResults, MaterializedResult materializedRows)
{
assertEquals(materializedRows.getTypes(), expectedTypes);
assertThat(materializedRows.getTypes()).isEqualTo(expectedTypes);
List<Object> actualResults = getOnlyElement(materializedRows).getFields();
assertEquals(actualResults.size(), expectedResults.size(), "lists don't have the same size");
verify(actualResults.size() == expectedResults.size(), "lists don't have the same size");
for (int i = 0; i < expectedResults.size(); i++) {
assertEquals(actualResults.get(i), expectedResults.get(i), "Element " + i);
}
Expand Down

0 comments on commit b378f1f

Please sign in to comment.