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. When you really do need to create your own strategy prefer to
extend AbstractFailureStrategy
rather than this class directly.
Alternatives to creating a custom FailureStrategy
implementation:
ExpectFailure
Subject.check()
Subject.ignoreCheck()
Constructor and Description |
---|
FailureStrategy() |
Modifier and Type | Method and Description |
---|---|
abstract void |
fail(String message)
Report an assertion failure with a text message.
|
abstract void |
fail(String message,
Throwable cause)
Report an assertion failure with a text message and a throwable that indicates the cause of the
failure.
|
abstract void |
failComparing(String message,
CharSequence expected,
CharSequence actual)
Convenience method to report string-comparison failures with more detail (e.g.
|
abstract void |
failComparing(String message,
CharSequence expected,
CharSequence actual,
Throwable cause)
Convenience method to report string-comparison failures with more detail (e.g.
|
public abstract void fail(String message)
fail(String, Throwable)
.public abstract void fail(String message, Throwable cause)
public abstract void failComparing(String message, CharSequence expected, CharSequence actual)
failComparing(String,
CharSequence, CharSequence, Throwable)
.public abstract void failComparing(String message, CharSequence expected, CharSequence actual, Throwable cause)
Copyright © 2017. All rights reserved.