-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add check(String template, Object... args), and use it to provide con…
…text like... - "value of: throwable.getCause().getMessage()" - "multimap was: <{1=[5]}>" This covers: - "high-level approach" issues A, A1, E - "Subject.check()" issues A, B, C This stops short of letting the existing no-arg check() contribute to a chain, thanks to outstanding questions around the right behavior in some edge cases. Any call to no-arg check() will throw away any "value of" string we've computed so far, and it won't trigger the inclusion of a "root." (Calls to check(String, Object...) elsewhere in the chain may still cause us to include one or both of "value of" and "root.") This also doesn't introduce any newlines into failure messages. Internally, the main parts of this are: - Make our custom ComparisonFailure accept a suffix (for use with "value of"). We need this because ComparisonFailure puts the user-specified message *before* the "expected: ...; but was: ..." text, and we want to put part of ours after. I've also added suffix support to our custom AssertionError. This might be avoidable, but it seems reasonable enough for the two classes to have similar APIs, especially because our GWT method for "give me a ComparisonFailure" actually returns a plain AssertionError. - In FailureMetadata, track the calls to check() alongside the calls to Subject constructors. - Make FailureMetadata.Message (currently used by withMessage()) available for use from check(). - Change MultimapSubject and ThrowableSubject to use the new API. RELNOTES=Added `check(String template, Object... args)`. Most users of `check()` should migrate. If the new method doesn't suit your needs, please [file a bug](https://github.com/google/truth/issues/new). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=186348792
- Loading branch information
1 parent
32ee988
commit 187a969
Showing
18 changed files
with
752 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.