public abstract class FailureStrategy extends Object
This type does not appear directly in a fluent assertion chain, but you choose a FailureStrategy
by choosing which StandardSubjectBuilder
-returning method to call.
TODO(cpovirk): Link to a doc about the full assertion chain.
Custom FailureStrategy
implementations are unusual. If you think you need one,
consider these alternatives:
ExpectFailure
.
Subject.check()
, which preserves the existing FailureStrategy
and other
context.
Subject.ignoreCheck()
When you really do need to create your own strategy, prefer to extend AbstractFailureStrategy
rather than this class directly. And rather than expose your FailureStrategy
instance to users, expose a StandardSubjectBuilder
instance using StandardSubjectBuilder.forCustomFailureStrategy(STRATEGY)
.
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.