/** * 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); }
/** * A generic, advanced method of extension of Truth to new types, which is documented on {@link * CustomSubjectBuilder}. Extension creators should prefer {@link Subject.Factory} if possible. */ public static <CustomSubjectBuilderT extends CustomSubjectBuilder> CustomSubjectBuilderT assertAbout( CustomSubjectBuilder.Factory<CustomSubjectBuilderT> factory) { return assert_().about(factory); }
/** * Given a factory for some {@code Subject} class, returns a builder whose {@code that(actual)} * method creates instances of that class. */ public static <S extends Subject<S, T>, T> SimpleSubjectBuilder<S, T> assertAbout( Subject.Factory<S, T> factory) { return assert_().about(factory); }
/** * 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); }
private static void failFormat(String template, Object... args) { assert_().fail(template, args); } }
public static <T extends Comparable<?>> ComparableSubject<?, T> assertThat( @NullableDecl T actual) { return assert_().that(actual); }
public static PrimitiveShortArraySubject assertThat(@NullableDecl short[] actual) { return assert_().that(actual); }
public static PrimitiveFloatArraySubject assertThat(@NullableDecl float[] actual) { return assert_().that(actual); }
public static SetMultimapSubject assertThat(@NullableDecl SetMultimap<?, ?> actual) { return assert_().that(actual); }
public static AtomicLongMapSubject assertThat(@NullableDecl AtomicLongMap<?> actual) { return assert_().that(actual); }
public static <T> ObjectArraySubject<T> assertThat(@NullableDecl T[] actual) { return assert_().that(actual); }
public static PrimitiveBooleanArraySubject assertThat(@NullableDecl boolean[] actual) { return assert_().that(actual); }
public static PrimitiveIntArraySubject assertThat(@NullableDecl int[] actual) { return assert_().that(actual); }
public static PrimitiveByteArraySubject assertThat(@NullableDecl byte[] actual) { return assert_().that(actual); }
public static PrimitiveDoubleArraySubject assertThat(@NullableDecl double[] actual) { return assert_().that(actual); }
public static MapSubject assertThat(@NullableDecl Map<?, ?> actual) { return assert_().that(actual); }
public static SortedMapSubject assertThat(@NullableDecl SortedMap<?, ?> actual) { return assert_().that(actual); }
public static MultisetSubject assertThat(@NullableDecl Multiset<?> actual) { return assert_().that(actual); }
@GwtIncompatible("ClassSubject.java") public static ClassSubject assertThat(@NullableDecl Class<?> actual) { return assert_().that(actual); }
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++; } }