-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Evaluate Truth assertion framework #1037
base: master
Are you sure you want to change the base?
Conversation
It is roughly equivalent to a single Hamcrest matcher, implemented with FeatureMatcher. At this point it might seem more verbose, but given this class, it seems easier to add new operations — one does not need the new FeatureMatchers, just new operations like `hasUrl()`.
It required just a single method 'hasUrlQueryParameter'. A possible alternative is to implement a subject for HttpUrl, but we do not seem to make any assertions on this object except the query parameter from the recorded request.
Looks nice.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Truth is nice, as is AssertJ. Error messages are almost the same IMO. Subjects seem easy to implement if needed. I think we could go with whichever, in simple cases (so most of the time) it wouldn't matter that much.
Thanks for the review,
The good thing is, Regarding Maps, I currently see several ways how to do that:
The big advantage of the second approach is that there is way less operations to implement (test, document) and maintain. There are a couple of disadvantages too: (a) unless we create an MapIndexToMapAdapter, they will always convert the MapIndex into Map in O(N) even for assertions using O(1) operations; (b) MapIndex is not a Map, therefore, some operations have different signatures (e.g., |
Looks nice.
I believe it's not a problem because usually there're not so many elements in test collections. |
Exactly, that's why I considered the overhead as "negligible" 🙃 |
There is something for a Testkit Px for sure. |
In AssertJ, one has to pass Map.Entry instances, which is less convenient: ``` assertThat(map).containsExactly(entry("hi", 1), ..., entry("service", 5)) ```
Overview
The PR is better viewed commit-by-commit. It starts with a singe test migrated to Truth, adds a minimal
Subject
(~ Hamcrest Matcher), then extends that subject with a new operation, and finally adds some assertions on common library types likeString
s andThrowable
s and various collections.See:
Definition of Done