-
Notifications
You must be signed in to change notification settings - Fork 93
Feat/write test fns for about util #395
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
Feat/write test fns for about util #395
Conversation
…functions Added tests for the following AboutUtil functions: - Non-UI functions: - onShareScribeClick - onMailClick - Composable functions: - getCommunityList (covers all items and their click behavior) - getFeedbackAndSupportList (covers callback and intent-triggered items) - getLegalListItems Note: `onRateScribeClick` test is pending.
Thank you for the pull request! ❤️The Scribe-Android team will do our best to address your contribution as soon as we can. If you're not already a member of our public Matrix community, please consider joining! We'd suggest using Element as your Matrix client, and definitely join the |
Maintainer ChecklistThe following is a checklist for maintainers to make sure this process goes as well as possible. Feel free to address the points below yourself in further commits if you realize that actions are needed :) |
|
Hi @angrezichatterbox 👋🏾, can you check out this PR? I have some issues writing the cc: @andrewtavis |
|
fixed the license issue :) can you explain why this is happening? Instrumentation? |
|
I will look into this PR tmrw evening. |
|
Hey, We decided on using Mockk for the project as it offered more advantages to the project in the long term due to the Mockk being more adjusted to use Kotlin rather than Mockito as it is more adjusted to use Java. Could the tests be migrated to use Mockk. |
Yes, it can. I'll try to do that. is that the reason why the teo tests are failing? |
|
It would be better to write instrumentation tests where Roboelectric has to be necessary used. I would recommend writing instrumentation tests for some of these rather than Unit tests as these deals with interaction with the device as well. |
|
okay, I'll look into it and share my feedback if any |
|
Hi @angrezichatterbox , here is an update on the testing issue. I have added new test cases and resolved the failing tests. cc: @andrewtavis |
|
Thanks for the great work, @DeleMike! @angrezichatterbox, let us know if anything further is needed here 😊 |
angrezichatterbox
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 for the PR @DeleMike. 2 of the tests are failing Could you look into that and also remove the Mockito dependencies. We will be using Mockk for the project as we had decided to use it during the initial discussion of tests.
Could you also look into the reports as I have detailed in #420 latest comment to see which parts have you missed.
|
Thank you @angrezichatterbox. For the reports, as discussed here, do you want me to paste the reports output here? And for the tests, I tried it again and they are all passing. Can you highlight the two tests that are failing? |
|
Ideally we'd also see failing tests in the PR jobs, @angrezichatterbox :) Is there a reason why the tests are passing? |
I'll get back to you on this later today. |
We haven't set it up for git actions for Instrumentation tests yet. |
Alright, I'll be waiting for a reply 😊 |
|
Thanks for letting me know about the action, @angrezichatterbox! @DeleMike, can you make an issue to add the instrumentation tests to the GitHub actions? Including the command to run would be great, and we could do |
@andrewtavis I will create the issue and I will tag you and @angrezichatterbox |
|
Hi @andrewtavis , I will work on this PR today. The main issue left here is, we need to wait for the Emulator to finish booting and I've been researching on how to make this possible. But I'll report my current status soon! I will resolve merge conflicts and work on it |
|
I have solved the merge conflicts, and the Android tests are passing on my device, but for some reason, the AndroidTests Github actions flow keeps failing. @andrewtavis @angrezichatterbox I will investigate further.
|
|
Nice that the tests are passing now, @DeleMike! Please let us know when this is ready for a review 😊 |
|
Hello @angrezichatterbox and @andrewtavis. The PR is ready for review. 🛠 Summary of Fixes for Failing Instrumented TestsI resolved two core issues affecting the tests (because they were passing on physical devices and not emulators):
Fix: I added a runtime check to append Intent.FLAG_ACTIVITY_NEW_TASK if the provided context is not an Activity: if (context !is Activity) {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
}
val scenario = ActivityScenario.launch(MainActivity::class.java)
scenario.onActivity { activity ->
AboutUtil.onShareScribeClick(activity)
}✅ All instrumentation tests now pass on the emulator started by our GitHub actions test and on physical devices. Please let me know if you need anything else. |
angrezichatterbox
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.
@DeleMike Everything looks good to me. Thanks for getting this done. We are getting around 91% coverage for AboutUtil which is quite nice.
I had made some additional changes to unit test as those could be migrated to junit 5. Instrumental test can remain in Junit 4 as it is the only way.
andrewtavis
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.
So great to have these tests up and running so early in the life of the application, @DeleMike! Thanks for the hard work here :) Quick note on comments: Would be good if ones that are their own line end with a period, but we don't need capitalization of the first letter or a period for inline comments. Thanks also for the review, @angrezichatterbox!

Contributor checklist
./gradlew lintKotlin detekt testcommand as directed in the testing section of the contributing guideDescription
This PR contains tests for the
AboutUtil.kt.Added tests for the following AboutUtil functions:
Non-UI functions:
Composable functions:
Note:
onRateScribeClicktest is pending. I don't know how to actually implement it. Or what to test...Also Note: I removed dependencies relating to
JUnit5. It was causing some conflicts when I tried to build/run the tests. I initially started writing withJUnit5but I had to remove it because existing codebase already usesJUnit4and I had an issue with Compose's compatibility withJUnit5Related issue