public class StandardSubjectBuilder extends Object
withMessage(java.lang.String)
.
Subject
to create with about(SubjectFactory)
.
Subject
built into Truth, directly specify the value under test
with that(Object)
.
TODO(cpovirk): Link to a doc about the full assertion chain.
TODO(cpovirk): Link to a doc about custom subjects.
Modifier and Type | Method and Description |
---|---|
<CustomSubjectBuilderT extends CustomSubjectBuilder> |
about(CustomSubjectBuilder.Factory<CustomSubjectBuilderT> factory) |
<CustomSubjectBuilderT extends CustomSubjectBuilder> |
about(CustomSubjectBuilderFactory<CustomSubjectBuilderT> factory)
Deprecated.
When you switch from
CustomSubjectBuilderFactory to CustomSubjectBuilder.Factory , you'll switch from this overload to the CustomSubjectBuilder.Factory overload. |
<S extends Subject<S,A>,A> |
about(Subject.Factory<S,A> factory)
Given a factory for some
Subject class, returns a builder whose that(actual)
method creates instances of that class. |
<S extends Subject<S,A>,A> |
about(SubjectFactory<S,A> factory)
Deprecated.
When you switch from
SubjectFactory to Subject.Factory , you'll
switch from this overload to the Subject.Factory overload. |
void |
fail()
Triggers the failure strategy with an empty failure message
|
void |
fail(String format,
Object... args)
Triggers the failure strategy with the given failure message
|
static StandardSubjectBuilder |
forCustomFailureStrategy(FailureStrategy failureStrategy)
Returns a new instance that invokes the given
FailureStrategy when a check fails. |
AtomicLongMapSubject |
that(com.google.common.util.concurrent.AtomicLongMap<?> actual) |
BigDecimalSubject |
that(BigDecimal actual) |
BooleanSubject |
that(Boolean actual) |
PrimitiveBooleanArraySubject |
that(boolean[] actual) |
PrimitiveByteArraySubject |
that(byte[] actual) |
PrimitiveCharArraySubject |
that(char[] actual) |
ClassSubject |
that(Class<?> actual) |
<ComparableT extends Comparable<?>> |
that(ComparableT actual) |
DoubleSubject |
that(Double actual) |
PrimitiveDoubleArraySubject |
that(double[] actual) |
FloatSubject |
that(Float actual) |
PrimitiveFloatArraySubject |
that(float[] actual) |
PrimitiveIntArraySubject |
that(int[] actual) |
IntegerSubject |
that(Integer actual) |
IterableSubject |
that(Iterable<?> actual) |
ListMultimapSubject |
that(com.google.common.collect.ListMultimap<?,?> actual) |
LongSubject |
that(Long actual) |
PrimitiveLongArraySubject |
that(long[] actual) |
MapSubject |
that(Map<?,?> actual) |
MultimapSubject |
that(com.google.common.collect.Multimap<?,?> actual) |
MultisetSubject |
that(com.google.common.collect.Multiset<?> actual) |
Subject<DefaultSubject,Object> |
that(Object actual) |
GuavaOptionalSubject |
that(com.google.common.base.Optional<?> actual) |
SetMultimapSubject |
that(com.google.common.collect.SetMultimap<?,?> actual) |
PrimitiveShortArraySubject |
that(short[] actual) |
SortedMapSubject |
that(SortedMap<?,?> actual) |
SortedSetSubject |
that(SortedSet<?> actual) |
StringSubject |
that(String actual) |
<T> ObjectArraySubject<T> |
that(T[] actual) |
TableSubject |
that(com.google.common.collect.Table<?,?,?> actual) |
ThrowableSubject |
that(Throwable actual) |
StandardSubjectBuilder |
withMessage(String messageToPrepend) |
StandardSubjectBuilder |
withMessage(String format,
Object... args)
Returns a
StandardSubjectBuilder that will prepend the formatted message using the
specified arguments to the failure message in the event of a test failure. |
public static StandardSubjectBuilder forCustomFailureStrategy(FailureStrategy failureStrategy)
FailureStrategy
when a check fails. Most
users should not need this. If you think you do, see the documentation on FailureStrategy
.public final <ComparableT extends Comparable<?>> ComparableSubject<?,ComparableT> that(@Nullable ComparableT actual)
public final BigDecimalSubject that(@Nullable BigDecimal actual)
public final Subject<DefaultSubject,Object> that(@Nullable Object actual)
@GwtIncompatible(value="ClassSubject.java") public final ClassSubject that(@Nullable Class<?> actual)
public final ThrowableSubject that(@Nullable Throwable actual)
public final LongSubject that(@Nullable Long actual)
public final DoubleSubject that(@Nullable Double actual)
public final FloatSubject that(@Nullable Float actual)
public final IntegerSubject that(@Nullable Integer actual)
public final BooleanSubject that(@Nullable Boolean actual)
public final StringSubject that(@Nullable String actual)
public final IterableSubject that(@Nullable Iterable<?> actual)
public final SortedSetSubject that(@Nullable SortedSet<?> actual)
public final <T> ObjectArraySubject<T> that(@Nullable T[] actual)
public final PrimitiveBooleanArraySubject that(@Nullable boolean[] actual)
public final PrimitiveShortArraySubject that(@Nullable short[] actual)
public final PrimitiveIntArraySubject that(@Nullable int[] actual)
public final PrimitiveLongArraySubject that(@Nullable long[] actual)
public final PrimitiveCharArraySubject that(@Nullable char[] actual)
public final PrimitiveByteArraySubject that(@Nullable byte[] actual)
public final PrimitiveFloatArraySubject that(@Nullable float[] actual)
public final PrimitiveDoubleArraySubject that(@Nullable double[] actual)
public final GuavaOptionalSubject that(@Nullable com.google.common.base.Optional<?> actual)
public final MapSubject that(@Nullable Map<?,?> actual)
public final SortedMapSubject that(@Nullable SortedMap<?,?> actual)
public final MultimapSubject that(@Nullable com.google.common.collect.Multimap<?,?> actual)
public final ListMultimapSubject that(@Nullable com.google.common.collect.ListMultimap<?,?> actual)
public final SetMultimapSubject that(@Nullable com.google.common.collect.SetMultimap<?,?> actual)
public final MultisetSubject that(@Nullable com.google.common.collect.Multiset<?> actual)
public final TableSubject that(@Nullable com.google.common.collect.Table<?,?,?> actual)
public final AtomicLongMapSubject that(@Nullable com.google.common.util.concurrent.AtomicLongMap<?> actual)
public final StandardSubjectBuilder withMessage(@Nullable String messageToPrepend)
public final StandardSubjectBuilder withMessage(@Nullable String format, Object... args)
StandardSubjectBuilder
that will prepend the formatted message using the
specified arguments to the failure message in the event of a test failure.
Note: The failure message template string only supports the "%s"
specifier,
not the full range of Formatter
specifiers.
IllegalArgumentException
- if the number of placeholders in the format string does not
equal the number of given arguments@Deprecated public final <S extends Subject<S,A>,A> SimpleSubjectBuilder<S,A> about(SubjectFactory<S,A> factory)
SubjectFactory
to Subject.Factory
, you'll
switch from this overload to the Subject.Factory
overload.Subject
class, returns a builder whose that(actual)
method creates instances of that class. Created subjects use the previously set failure
strategy and any previously set failure message.public final <S extends Subject<S,A>,A> SimpleSubjectBuilder<S,A> about(Subject.Factory<S,A> factory)
Subject
class, returns a builder whose that(actual)
method creates instances of that class. Created subjects use the previously set failure
strategy and any previously set failure message.@Deprecated public final <CustomSubjectBuilderT extends CustomSubjectBuilder> CustomSubjectBuilderT about(CustomSubjectBuilderFactory<CustomSubjectBuilderT> factory)
CustomSubjectBuilderFactory
to CustomSubjectBuilder.Factory
, you'll switch from this overload to the CustomSubjectBuilder.Factory
overload.CustomSubjectBuilder
. Extension creators should prefer Subject.Factory
if possible.public final <CustomSubjectBuilderT extends CustomSubjectBuilder> CustomSubjectBuilderT about(CustomSubjectBuilder.Factory<CustomSubjectBuilderT> factory)
public final void fail()
Copyright © 2017. All rights reserved.