-
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.
Improve the failure messages from MapSubject.containsExactly and cont…
…ainsExactlyElementsIn (and, in a more minor way, isEqualTo). The most important change is to containsExactly and containsExactlyElementsIn's any-order assertions. These now report separately keys which are missing, unexpected, or present with the wrong value. Previously, they only reported missing or unexpected entries (which they referred to as either 'items'). The other changes to containsExactly and containsExactlyElementsIn are: - The in-order assertions now refer to entries as 'entries' rather than 'elements'. - They now use the standard Map formatting of {k1=v1, k2=v2} (as used by Map.toString and other MapSubject assertions). Previously, they used the non-standard [k1=v1, k2=v2]. - The any-order assertions where keys or values are toString-equal now give the types of the keys or values rather than the types of the entries. We already provide the pairing behaviour for isEqualTo. The changes there are: - The text of the messages is a bit more explicit. Previously, it said "missing the following entries" for the cases where there are no entries with the expected keys, "has the following extra entries" for the cases where there are entries with unexpected keys, and "has the following different entries" for the cases where there are matching keys with different values, which all seemed a bit unclear. - For a key diff where a key 123 was expected to have value "foo" but had value "bar", it formats the diff as "123=(expected foo but got bar)". Previously, it said "123=(foo, bar)" which was rather opaque (especially if the values have long toString()s which only differ slightly). - It says "It has..." instead of "The subject has...", to be more consistent with other assertions (and avoid the disfavoured "subject" terminology). - Where keys or values are toString-equal it now give the types of the keys or values rather than the types of the entries. - It has special handling for the case where the diff is empty but equals returns false (i.e. the Map implementation violates its contract). Previously, it would say "Not true that <...> is equal to <...>. The subject" and then just stop. The test coverage is also improved. This also fixes a couple of tests of test helpers which made assertions about the failure messages Truth would produce. RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=177790307
- Loading branch information
1 parent
4066d17
commit aad4f3a
Showing
2 changed files
with
366 additions
and
49 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
Oops, something went wrong.