Skip to content

Commit

Permalink
Deprecate failWithRawMessageAndCause.
Browse files Browse the repository at this point in the history
RELNOTES=Deprecated `failWithRawMessageAndCause`. Truth automatically attaches the cause if it's part of the assertion chain. If not, see the deprecation docs for the workaround.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=192171600
  • Loading branch information
cpovirk authored and ronshapiro committed Apr 11, 2018
1 parent 2db2a4f commit 3622e9c
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions core/src/main/java/com/google/common/truth/Subject.java
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,19 @@ protected void failWithRawMessage(String message, Object... parameters) {
metadata.fail(format(message, parameters));
}

/** Passes through a failure message verbatim, along with a cause. */
/**
* Passes through a failure message verbatim, along with a cause.
*
* @deprecated Pass the message to {@link #failWithRawMessage}, but also, to make Truth attach the
* {@code Throwable cause} to the assertion failure, ensure that {@code cause} appears in the
* assertion chain. This should typically already be the case, as in {@code
* assertThat(throwable).hasMessageThat().isEqualTo("message")}. If it is not, you will need
* to introduce an extra {@code check} call into your chain, something like {@code
* check().about(unexpectedFailures()).that(cause).wasASuccess(message)}, with {@code
* unexpectedFailures()} returning a factory for a "dummy" subject type that defines only a
* {@code wasASuccess} method that fails unconditionally.
*/
@Deprecated
protected final void failWithRawMessageAndCause(String message, Throwable cause) {
metadata.fail(message, cause);
}
Expand Down Expand Up @@ -985,11 +997,7 @@ protected final void failComparing(String message, CharSequence expected, CharSe
* @deprecated See {@linkplain #failComparing(String, CharSequence, CharSequence)} the other
* overload of this method for instructions on how to get Truth to throw a {@code
* ComparisonFailure}. To make Truth also attach the {@code Throwable cause} to the assertion
* failure, ensure that {@code cause} appears in the assertion chain. This should typically
* already be the case, as in {@code
* assertThat(throwable).hasMessageThat().isEqualTo("message")}. If it is not, you will need
* to introduce an extra {@code check(cause)} call into your chain. (We haven't encountered
* this in Google's codebase. If you do, we're happy to provide more information.)
* failure, see the instructions on {@link #failWithRawMessageAndCause}.
*/
@Deprecated
protected final void failComparing(
Expand Down

0 comments on commit 3622e9c

Please sign in to comment.