-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Port Junit test to Truth in the package com.google.gson
of the module gson
#2299
Conversation
This is fantastic! Thanks very much for doing it. I hope you were able to automate most of the transformations. Only minor comments... |
Most welcome!
What comments? |
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.
It would help if I published the comments!
JsonPrimitive p2 = new JsonPrimitive(Short.valueOf((short)10)); | ||
assertEquals(p1, p2); | ||
assertEquals(p1.hashCode(), p2.hashCode()); | ||
JsonPrimitive p1 = new JsonPrimitive((byte) 10); |
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.
Not in this PR, but I think it might make sense to introduce a test-scoped dependency on com.google.guava:guava-testlib
. A large number of the assertions in this class could be reduced to a single large call to EqualsTester
. It checks that test objects in the same "equality group" are all pairwise equal and have equal hash-codes, and that objects not in the same "equality group" are not equal.
We could also use guava-testlib
to simplify JsonArrayAsListTest
and JsonObjectAsMapTest
and probably some other tests, via ListTestSuiteBuilder
and the like, though the JUnit 3 API is unfortunate. Again, not in this PR, but worth thinking about.
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.
Yeah, make sense. Probably the next step would be implement Truth in all of the nested packages. After that we could think to implement guava and simplify some tests.
…That(e).hasMessageThat().isEqualTo(...)`
Thanks again! |
…le `gson` (google#2299) * Add the Truth dependency * Port Junit test to Truth in the package `com.google.gson` of the module `gson` * Replace the `assertThat(e.getMessage()).isEqualTo(...)"` with `assertThat(e).hasMessageThat().isEqualTo(...)` * Minor fixes
I have port Junit test to Truth in the package
com.google.gson
of the modulegson
The port doesn't involve the nested packages:
com.google.gson.common
com.google.gson.functional
com.google.gson.internal
com.google.gson.metrics
com.google.gson.reflect
com.google.gson.regression
com.google.gson.stream
Note: I also cleanup the code (For example: remove unnecessary unboxing & remove unused
throws
clausole)