Skip to content

Commit

Permalink
Improves error messages for prefab values
Browse files Browse the repository at this point in the history
  • Loading branch information
jqno committed Aug 2, 2023
1 parent 334bdc2 commit fea9162
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,13 @@ private static <T> void validateExampleIsUnequal(T example, List<T> equalExample
}

public static <T> void validateRedAndBluePrefabValues(Class<T> type, T red, T blue) {
validateNotNull(type, "type is null.");
validateNotNull(red, "red value is null.");
validateNotNull(blue, "blue value is null.");
validate(red.equals(blue), "both values are equal.");
validateNotNull(type, "prefab value type is null.");
validateNotNull(red, "red prefab value of type " + type.getSimpleName() + " is null.");
validateNotNull(blue, "blue prefab value of type " + type.getSimpleName() + " is null.");
validate(
red.equals(blue),
"both prefab values of type " + type.getSimpleName() + " are equal."
);
}

public static <T> void validateGenericPrefabValues(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ public void throw_whenThePrefabValuesAreTheSame() {
.withPrefabValues(FinalPoint.class, red, red)
)
.assertThrows(IllegalStateException.class)
.assertMessageContains("Precondition", "both values are equal");
.assertMessageContains(
"Precondition",
"both prefab values of type FinalPoint are equal"
);
}

@Test
Expand All @@ -76,7 +79,10 @@ public void throw_whenThePrefabValuesAreEqual() {
.withPrefabValues(FinalPoint.class, red1, red2)
)
.assertThrows(IllegalStateException.class)
.assertMessageContains("Precondition", "both values are equal");
.assertMessageContains(
"Precondition",
"both prefab values of type FinalPoint are equal"
);
}

@Test
Expand Down

0 comments on commit fea9162

Please sign in to comment.