/** * Returns a {@link StandardSubjectBuilder} that will prepend the given message to the failure * message in the event of a test failure. */ public static StandardSubjectBuilder assertWithMessage(String messageToPrepend) { return assert_().withMessage(messageToPrepend); }
public final StandardSubjectBuilder withMessage(@NullableDecl String messageToPrepend) { return withMessage("%s", messageToPrepend); }
/** * Returns a {@link StandardSubjectBuilder} that will prepend the formatted message using the * specified arguments to the failure message in the event of a test failure. * * <p><b>Note:</b> the arguments will be substituted into the format template using {@link * com.google.common.base.Strings#lenientFormat Strings.lenientFormat}. Note this only supports * the {@code %s} specifier. * * @throws IllegalArgumentException if the number of placeholders in the format string does not * equal the number of given arguments */ public static StandardSubjectBuilder assertWithMessage(String format, Object... args) { return assert_().withMessage(format, args); }
/** Returns a {@code StringSubject} to make assertions about the throwable's message. */ public final StringSubject hasMessageThat() { StandardSubjectBuilder check = check("getMessage()"); if (actual() instanceof ErrorWithFacts && ((ErrorWithFacts) actual()).facts().size() > 1) { check = check.withMessage( "(Note from Truth: When possible, instead of asserting on the full message, assert" + " about individual facts by using ExpectFailure.assertThat.)"); } return check.that(actual().getMessage()); }
public void test() { assertUsedAsRule(); isUsedWithoutCallingTest = false; tester.test(); assertThat(regressionTests).isNotEmpty(); int i = 1; for (Entry<Key, String> entry : regressionTests.entrySet()) { assert_() .withMessage( "Unexpected digest for regression test [" + i + "]: with key: " + entry.getKey()) .that(sha256.getStringDigest(entry.getKey())).isEqualTo(entry.getValue()); i++; } }
check = check.withMessage("key is present but with a different value");
@Override public void tick(TimeLapse timeLapse) { final List<RoadUser> list = model.getObjects().asList(); for (int i = 0; i < list.size(); i++) { for (int j = i + 1; j < list.size(); j++) { final Point p1 = model.getPosition(list.get(i)); final Point p2 = model.getPosition(list.get(j)); assert_() .withMessage("%s is too close to %s", list.get(i), list.get(j)) .that(Point.distance(p1, p2)) .isAtLeast(599d); } } }
.withMessage( "diversion: " + diversionIsAllowed + ", delayed route changes: " + allowDelayedRouteChanges + ", routeAdjuster: " + routeAdjuster)