-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Test JSObject #2508
Test JSObject #2508
Conversation
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.
Thanks for this! I've been a bit concerned with the lack of tests in the Capacitor code so it'd be great to have some.
android/capacitor/build.gradle
Outdated
@@ -54,6 +54,9 @@ dependencies { | |||
implementation 'com.google.firebase:firebase-messaging:18.0.0' | |||
implementation 'com.google.android.gms:play-services-location:17.0.0' | |||
testImplementation 'junit:junit:4.12' | |||
testImplementation 'org.json:json:20140107' | |||
|
|||
|
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.
I'm not sure this is needed. The only import the test code has that uses this is import org.json.JSONException;
and that's included in Android API.
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.
This is needed to prevent java.lang.RuntimeException: Method getString in org.json.JSONObject not mocked. See http://g.co/androidstudio/not-mocked for details.
errors as JSON
is bundled with Android and thus hitting a stub, so a real JSON implementation is needed to drive a real valuable test.
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.
OK, that explanation is fine with me.
android/capacitor/src/test/java/com/getcapacitor/JSObjectTest.java
Outdated
Show resolved
Hide resolved
@imjacobclark Any comment on the above review? Also, this repo uses GitHub Actions, would you be able to update the PR? |
Hey @dwieeb @smpeters thanks for the review - it’s on my todo list to fix this up, I’ll get around to it tomorrow I think! |
LGTM! Thanks for getting Capacitor set up with testing in Java. 😅 |
@dwieeb no problem! What’s the process to get this merged in? |
Couple things yet... @smpeters Would you care to comment further or resolve the conversation in your review? |
LGTM |
First contribution here...
I plan on contributing more than these tests in this PR, but I chose JSObject as a first good place to start.
Feedback/thoughts welcome!
Thanks