public class StandardSubjectBuilder extends TestVerb
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.
AbstractVerb.DelegatedVerb<S extends Subject<S,T>,T>
Modifier and Type | Method and Description |
---|---|
<CustomSubjectBuilderT extends CustomSubjectBuilder> |
about(CustomSubjectBuilderFactory<CustomSubjectBuilderT> factory)
A generic, advanced method of extension of Truth to new types, which is documented on
CustomSubjectBuilder . |
<S extends Subject<S,A>,A,SF extends SubjectFactory<S,A>> |
about(SF factory)
Given a factory for some
Subject class, returns a builder whose that(actual)
method creates instances of that class. |
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<?> target) |
BigDecimalSubject |
that(BigDecimal target) |
BooleanSubject |
that(Boolean target) |
PrimitiveBooleanArraySubject |
that(boolean[] target) |
PrimitiveByteArraySubject |
that(byte[] target) |
PrimitiveCharArraySubject |
that(char[] target) |
ClassSubject |
that(Class<?> target) |
DoubleSubject |
that(Double target) |
PrimitiveDoubleArraySubject |
that(double[] target) |
FloatSubject |
that(Float target) |
PrimitiveFloatArraySubject |
that(float[] target) |
PrimitiveIntArraySubject |
that(int[] target) |
IntegerSubject |
that(Integer target) |
IterableSubject |
that(Iterable<?> target) |
ListMultimapSubject |
that(com.google.common.collect.ListMultimap<?,?> target) |
LongSubject |
that(Long target) |
PrimitiveLongArraySubject |
that(long[] target) |
MapSubject |
that(Map<?,?> target) |
MultimapSubject |
that(com.google.common.collect.Multimap<?,?> target) |
MultisetSubject |
that(com.google.common.collect.Multiset<?> target) |
Subject<DefaultSubject,Object> |
that(Object target) |
GuavaOptionalSubject |
that(com.google.common.base.Optional<?> target) |
SetMultimapSubject |
that(com.google.common.collect.SetMultimap<?,?> target) |
PrimitiveShortArraySubject |
that(short[] target) |
SortedMapSubject |
that(SortedMap<?,?> target) |
SortedSetSubject |
that(SortedSet<?> target) |
StringSubject |
that(String target) |
<T extends Comparable<?>> |
that(T target) |
<T> ObjectArraySubject<T> |
that(T[] target) |
TableSubject |
that(com.google.common.collect.Table<?,?,?> target) |
ThrowableSubject |
that(Throwable target) |
StandardSubjectBuilder |
withMessage(String messageToPrepend)
Overrides the failure message of the subsequent subject's propositions.
|
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. |
about, getFailureStrategy
getFailureMessage, hasFailureMessage
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 <T extends Comparable<?>> ComparableSubject<?,T> that(@Nullable T target)
public final BigDecimalSubject that(@Nullable BigDecimal target)
public final Subject<DefaultSubject,Object> that(@Nullable Object target)
@GwtIncompatible(value="ClassSubject.java") public final ClassSubject that(@Nullable Class<?> target)
public final ThrowableSubject that(@Nullable Throwable target)
public final LongSubject that(@Nullable Long target)
public final DoubleSubject that(@Nullable Double target)
public final FloatSubject that(@Nullable Float target)
public final IntegerSubject that(@Nullable Integer target)
public final BooleanSubject that(@Nullable Boolean target)
public final StringSubject that(@Nullable String target)
public final IterableSubject that(@Nullable Iterable<?> target)
public final SortedSetSubject that(@Nullable SortedSet<?> target)
public final <T> ObjectArraySubject<T> that(@Nullable T[] target)
public final PrimitiveBooleanArraySubject that(@Nullable boolean[] target)
public final PrimitiveShortArraySubject that(@Nullable short[] target)
public final PrimitiveIntArraySubject that(@Nullable int[] target)
public final PrimitiveLongArraySubject that(@Nullable long[] target)
public final PrimitiveCharArraySubject that(@Nullable char[] target)
public final PrimitiveByteArraySubject that(@Nullable byte[] target)
public final PrimitiveFloatArraySubject that(@Nullable float[] target)
public final PrimitiveDoubleArraySubject that(@Nullable double[] target)
public final GuavaOptionalSubject that(@Nullable com.google.common.base.Optional<?> target)
public final MapSubject that(@Nullable Map<?,?> target)
public final SortedMapSubject that(@Nullable SortedMap<?,?> target)
public final MultimapSubject that(@Nullable com.google.common.collect.Multimap<?,?> target)
public final ListMultimapSubject that(@Nullable com.google.common.collect.ListMultimap<?,?> target)
public final SetMultimapSubject that(@Nullable com.google.common.collect.SetMultimap<?,?> target)
public final MultisetSubject that(@Nullable com.google.common.collect.Multiset<?> target)
public final TableSubject that(@Nullable com.google.common.collect.Table<?,?,?> target)
public final AtomicLongMapSubject that(@Nullable com.google.common.util.concurrent.AtomicLongMap<?> target)
public final StandardSubjectBuilder withMessage(@Nullable String messageToPrepend)
AbstractVerb
withMessage
in class TestVerb
messageToPrepend
- a descriptive message.com.google.common.truth.delegation.DelegationTest
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.
withMessage
in class TestVerb
format
- a descriptive message with formatting template content.args
- object parameters to be substituted into the message template.IllegalArgumentException
- if the number of placeholders in the format string does not
equal the number of given argumentscom.google.common.truth.delegation.DelegationTest
public final <S extends Subject<S,A>,A,SF extends SubjectFactory<S,A>> SimpleSubjectBuilder<S,A> about(SF 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.about
in class AbstractVerb<TestVerb>
factory
- a SubjectFactory<S, D>
implementationcom.google.common.truth.delegation.DelegationTest
public final <CustomSubjectBuilderT extends CustomSubjectBuilder> CustomSubjectBuilderT about(CustomSubjectBuilderFactory<CustomSubjectBuilderT> factory)
CustomSubjectBuilder
. Extension creators should prefer SubjectFactory
if possible.public final void fail()
fail
in class AbstractVerb<TestVerb>
Copyright © 2017. All rights reserved.