Refactor lenientFormat usages for improved failure messages

This commit modernizes failure messages in Truth by replacing
several usages of `com.google.common.base.Strings.lenientFormat`
with direct `String.format` calls or by restructuring messages
to use `Fact` objects, aiming for more helpful and structured
output for you.

Key changes include:

- In `Subject.java`, deprecated failure methods (`failWithBadResults`,
  `failWithCustomSubject`, `failWithoutSubject`) were updated to
  use `Fact` objects or direct string concatenation, removing
  `lenientFormat`.
- In `LiteProtoSubject.java`, failure messages for `isEqualTo` (class
  mismatch), `isNotEqualTo`, `isEqualToDefaultInstance`, and
  `isNotEqualToDefaultInstance` were refactored to use `Fact`-based
  constructions.
- In various helper methods within `IterableSubject.java`,
  `MapSubject.java`, `MultimapSubject.java` (partial), `SubjectUtils.java`,
  and `LazyMessage.java`, `lenientFormat` was replaced with
  `String.format` for consistency in message and component formatting.
- Usages of `lenientFormat` in `Correspondence.java` and parts of
  `MultimapSubject.java` that were for internal descriptive strings,
  not directly for user-facing Fact messages, were left unchanged
  based on your feedback.
- Test files were not modified as the existing core tests passed after
  these changes.

The goal of this refactoring was to improve the clarity and utility
of failure messages by adopting more structured `Fact` instances where
appropriate and ensuring consistent string formatting.
4 files changed
tree: e452c88e06be9ec4e70df2501c6b4742c08974d4
  1. .github/
  2. core/
  3. extensions/
  4. javadoc-link/
  5. refactorings/
  6. util/
  7. .gitignore
  8. CONTRIBUTING.md
  9. lenientFormat_usages.txt
  10. LICENSE
  11. overview.html
  12. pom.xml
  13. README.md
README.md

Main Site Build Status Maven Release Stackoverflow

What is Truth?

Truth makes your test assertions and failure messages more readable. Similar to AssertJ, it natively supports many JDK and Guava types, and it is extensible to others.

Truth is owned and maintained by the Guava team. It is used in the majority of the tests in Google’s own codebase.

Read more at the main website.