Changes include:
- update Guice tests that asserts error messages
- export new errors tests
- update Guice compiler flag so parameter names are available at runtime, which is required for the errors tests
PiperOrigin-RevId: 337602195
Changes include:
- update Guice tests that asserts error messages
- export new errors tests
- update Guice compiler flag so parameter names are available at runtime, which is required for the errors tests
PiperOrigin-RevId: 337401912
Renames may include:
- containsAllOf => containsAtLeast
- containsAllIn => containsAtLeastElementsIn
- isSameAs => isSameInstanceAs
- isOrdered => isInOrder
- isStrictlyOrdered => isInStrictOrder
The other major change is to change custom subjects to extend raw Subject instead of supplying type parameters. The type parameters are being removed from Subject. This CL will temporarily produce rawtypes warnings, which will go away when I remove the type parameters (as soon as this batch of CLs is submitted).
Some CLs in this batch also migrate calls away from actualAsString(). Its literal replacement is `"<" + actual + ">"` (unless an object overrides actualCustomStringRepresentation()), but usually I've made a larger change, such as switching from an old-style "Not true that..." failure message to one generated with the Fact API. In that case, the new code usually contains a direct reference to this.actual (a field that I occasionally had to create). Another larger change I sometimes made is to switch from a manual check-and-fail approach to instead use check(...). And sometimes I just remove a withMessage() call that's no longer necessary now that the code uses check(...), or I introduce a check(...) call. (An assertion made with check(...) automatically includes the actual value from the original subject, so there's no need to set it again with withMessage().)
Finally, there's one CL in this batch in which I migrate a Correspondence subclass to instead use Correspondence.from.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=251472122
The overload that accepts a description generally produces better failure messages:
- The first line of the message it produces is something like: "value of: myProto.getResponse()" (where "getResponse()" is taken from the provided description)
- The last line of the message it produces is something like: "myProto was: response: query was throttled" (the full value of myProto)
- And the existing text goes in between.
Additional motivation: We are deleting the no-arg overload externally (and probably internally thereafter).
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=247095743
Also, update the bundled-for-Ant JUnit from JUnit 3-something to JUnit 4.11. This matches the dependency used by the Maven build. It's necessary to avoid the problem "java.lang.ClassNotFoundException: org.junit.ComparisonFailure." Truth was already using that type as of 0.36[*], so I suspect that we were just getting away with the JUnit 3 dependency because of the vagaries of class loading. Presumably, if a test had ever actually failed in a way that should have produced a ComparisonFailure, the current build setup would have produces the same error.
[*] https://github.com/google/truth/blob/release_0_36/core/src/main/java/com/google/common/truth/Platform.java#L24
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=200574789
And discover the bound fields when constructing the module, but deferring the errors to configure() time.
This enables using BoundFieldModule with custom scoping in GuiceBerry/Acai using TestScopeListener/TestingService to reflectively reset the instance before tests.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=196814191
I'm sorry that the replacement is so ugly. Our reason for not supporting this directly is partially that it's needed by only ~1% of subjects. But mostly, we've over time taken the position that Truth is intended for only the "assert" phases of the "arrange, act, assert" testing process. Exceptions, on the other hand, usually come from the earlier phases.
Unfortunately, I still owe everyone a long explanation of *why* we have come to this position. If it's bugging you now, let me know, and I can make it happen.
(And yes, in this particular case, we're basically arguing that Your Subject Is Wrong. Sorry: I'm not trying to get you to delete it or recant or anything; I'm just trying to explain where we're coming from.)
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=192278109
We now accept (sigh) 3 versions:
- The version generated by the latest open-source release of Truth.
- The version generated by the current internal version of Truth.
- The version that will be generated once I submit CL 185043225.
I continue to promise to reduce this back to expecting a single version once I release a version of Truth that contains CL 185043225.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190771332
Before:
some messsage: the main message
After:
some message
the main message
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=189625749
Also changed truth.SubjectFactory to truth.Subject.Factory (plain renaming) and use method reference instead of anonymous class to create the factory when applicable.
FailureMetadata, an opaque object to its users, is introduced to replace FailureStrategy in in custom Subject in order to resolve some existing flaws of FailureStrategy as well as enable new features to be added to Truth.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171466733
The new this.fail* methods are available in Truth 0.36, which I've imported into the [] Maven repository for people who use that. If I could find a pom/build.xml for your open-source project, this CL updates it.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=169571495
configure a presubmit to ensure that it stays formatted.
Highlights include:
* simplified import order
* method annotations are now consistently defined on the preceding line
* javadoc reformatted to 100 chars column width
One test that contained line numbers in error messages had to be modified and
the formatter didn't like some of the more complicated preprocessor directives
(MOE and AOP).
To avoid formatting the copyright notices as javadoc i did a preprocessing step to rewrite the initial '/**' to '/*' using perl
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=132692207
This is useful for testing behavior of bindings when they fail with provision
exceptions.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=124735046
-Rename a test case for consistency
-Add a test for a nullable non-transparent Provider
-Use BoundFieldInfo#allowsNull and consolidate getting a field value in getFieldValue(), regardless of whether the field type is a simple field or a "transparent provider".
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=123686167
Fields annotated with some @Nullable annotation are allowed to have null values bound for testing, following how Guice works with null (https://github.com/google/guice/wiki/UseNullable)
This allows for easy testing of null cases without resorting to SettableProvider.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=123677621
Before this patch a ClassCastException would be thrown if a
javax.inject.Provider was used with @Bind, because the code would try to cast it
to com.google.inject.Provider.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=105098115