public abstract class FailureStrategy extends Object
FailureStrategy
defines how assertion failures are handled. In Truth
, failures
throw AssertionErrors; other assertion entry-points like
Expect
and TruthJUnit.assume()
have different failure behavior.
It should generally be unnecessary for Truth SPI developers to define their own FailureStrategy
implementations, they should instead use Subject.check()
to invoke other
subjects using the current strategy. When you really do need to create your own strategy prefer
to extend AbstractFailureStrategy
rather than this class directly.
Implementation Note: the concrete methods in this class will be made abstract in the near
future (see b/37472530); please do not depend on these existing implementations in new code,
prefer AbstractFailureStrategy
.
Constructor and Description |
---|
FailureStrategy() |
Modifier and Type | Method and Description |
---|---|
void |
fail(String message)
Report an assertion failure with a text message.
|
void |
fail(String message,
Throwable cause)
Report an assertion failure with a text message and a throwable that indicates the cause of the
failure.
|
void |
failComparing(String message,
CharSequence expected,
CharSequence actual)
Convenience method to report string-comparison failures with more detail (e.g.
|
void |
failComparing(String message,
CharSequence expected,
CharSequence actual,
Throwable cause)
Convenience method to report string-comparison failures with more detail (e.g.
|
public void fail(String message)
fail(String, Throwable)
.public void fail(String message, Throwable cause)
public void failComparing(String message, CharSequence expected, CharSequence actual)
failComparing(String,
CharSequence, CharSequence, Throwable)
.public void failComparing(String message, CharSequence expected, CharSequence actual, Throwable cause)
Copyright © 2017. All rights reserved.