-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add junit-gtest sample #437
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
Conversation
|
@fsladkey Thanks for adding this sample for junit-gtest. It's awesome. Hi @brettchabot , what about helping to review this PR? |
brettchabot
left a comment
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 Fred!
Consider adding a README.md.
Also consider adding this project to projects.conf so it gets tested on androidx.test library updates.
I don't have a strong opinion on location but I think unit/BasicNativeAndroidTest would work too.
.../GTestExample/app/src/androidTest/java/com/example/android/testing/nativesample/AdderTest.kt
Show resolved
Hide resolved
| import org.junit.runner.RunWith | ||
|
|
||
| @RunWith(GtestRunner::class) | ||
| @TargetLibrary(libraryName = "adder-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.
What about adding a Java version sample too?
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.
That's a good idea, unfortunately there's currently a limitation where only one GtestRunner can exist at a a time so duplicating the test in Java throws an error. It would be great to remove this limitation and I'm hoping to but until then I'm not sure there's a clean way to have both.
I'd also be happy to replace the Kotlin sample with Java is you think that's better. They are nearly identical anyway.
|
Thanks for the reviews folks! I think I addressed most of the comments and added a readme. I also tested the |
| } | ||
| apply plugin: 'kotlin-android' | ||
|
|
||
| android { |
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 haven't gotten around to filing a bug for this, but consumers of junit-gtest actually need to exclude some cruft that's included in the AAR or it will end up in the APK: https://github.com/DanAlbert/ndk-app-template/blob/6f46d2f49e68d20c102eb2122262716564f191d2/app/build.gradle#L42-L48 (in this example you don't want to exclude libc++_shared since this build is using libc++_shared; the example I linked uses the static lib)
Not sure if you want to include that workaround in this example, or fix the bug before submitting this. I'm fine either way.
The rest LGTM though.
Hi there!
As mentioned in #382, there aren't currently any samples (here or elsewhere) for how to use the
androidx-test-ext:junit-gtestlibrary, so I've put together a minimal sample project.This is not a particularly realistic example, but hopefully it will still be helpful as a guide for wiring everything together and could perhaps be expanded on in the future.
I based this on
ui/screenshot/ScreenshotSample, to avoid deviating too far from the other samples. But definitely let me know if there's anything I should fix.I'm not sure the directory placement is appropriate, I made a new directory called "native" because I wasn't sure the best way to categorize this sample (it's running unit tests, but on device 🤔). So just let know if there is a better spot for it.
Hope this is helpful! Thanks! :)