-
Notifications
You must be signed in to change notification settings - Fork 9
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
Make some tests run on roblectric #188
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e24d6e1
to
b3bd3d6
Compare
Make an exception for one test in `TestPoemFile`, which breaks starting with api level 31.
This allows us to get a test coverage report without having to run both robolectric and instrumentation tests.
…H` intent action.
Some functions in these test files aren't yet ready to be run on robolectric. Only move the test functions that can run on robolectric for now.
…est nullable. When we add the equivalent class in the test source set, it will be a no-op (it will return null).
* Add multi-activity support: - Actually start the next activity: - `MyShadowInstrumentation`: extend `ShadowInstrumentation` to actually launch an activity, in `execStartActivity()`. - Manage activity life cycle changes when starting another activity: - `MyShadowActivity`: - Make `startActivity[ForResult]` put *this* activity on pause after starting the *next* activity. - Make `finish()` put the *previous* activity (if any) in resume, after finishing *this* activity. - Cleanup: - `MyShadowActivity`: Be sure to clean up (close) the `ActivityScenario` of started activities, when they finish. * `MyShadowSearchManager`: - Make `getSearchableInfo()` actually return a `SearcheableInfo` (requires reflection). This was a no-op in Robolectric, which made the search functionality in the app not work from Robolectric.
* Add the sharedTest folder to the `test` source set. * Add necessary dependencies to the `test` source set. * Add basic implementations of some classes which are also in the androidTest source set: - ca/rmen/android/poetassistant/InstrumentationThreading.kt - ca/rmen/android/poetassistant/dagger/TestResultListModule.kt * Allow db queries on the main thread, only for robolectric tests
b3bd3d6
to
3660de1
Compare
24a8650
to
42da864
Compare
These tests seem to be not flaky, even when run on devices.
d00ec33
to
38e5dd5
Compare
This is just so we remember that this option exists. By default we're not using orchestrator anyway. If we need to re-enable orchestrator, we can see then whether to keep or remove `clearPackageData`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Project configuration:
test
andandroidTest
source sets.Application code modifications:
MainActivity
'sonCreate()
is called instead ofonNewIntent()
. AdaptonCreate()
to handle theSEARCH
action.Test code modifications:
Adaptations required to make tests run on Robolectric:
UnconfinedTestDispatcher
.MyShadowInstrumentation
: extendShadowInstrumentation
to actually launch an activity, inexecStartActivity()
.MyShadowActivity
:startActivity[ForResult]
put this activity on pause after starting the next activity.finish()
put the previous activity (if any) in resume, after finishing this activity.MyShadowActivity
: Be sure to clean up (close) theActivityScenario
of started activities, when they finish.MyShadowSearchManager
:getSearchableInfo()
actually return aSearcheableInfo
(requires reflection). This was a no-op in Robolectric, which made the search functionality in the app not work from Robolectric.Other:
TestPoemFile
, which has an issue saving the poem text starting with api level 31.RetryTestRule
on tests which seem flaky.