Open BenHenning opened 3 years ago
@BenHenning Would like to work upon this! Can I self assign?
@BenHenning Would like to work upon this! Can I self assign?
@dipu989 Yes you can self-assign.
@rt4914 @BenHenning How I am thinking about going with this issue is - Viewing the Project structure, we have sharedTest and test directories. I have to move the tests from "test" directory to the "sharedTest" directory in their respective counterparts and refactor if needed.
I have few doubts here - 1) I need to add @RunOn(ROBOELECTRIC) annotation in every test.kt file which are already using @RunWith(AndroidJunit4::class). Do these Junit annotations need to be replaced with Roboelectric ones above every class declaration?
2) Can you elaborate a bit more on the point 'Removing the Gradle/Bazel code around the app module test folder'.
@dipu989 good questions. I hope this will help clarify:
@dipu989 any update on this?
@anandwana001 I might get this done by the beginning of the next week. Sorry for blocking this for quite a long time.
@BenHenning @anandwana001 Local tests are passing but the instrumentation ones are giving this error. Any pointers to resolve this? Running on Realme device as well as emulator gives this error.
Gradle sync, invalid cache and restart, clean and rebuild project helps here. Take pull from latest develop branch.
@anandwana001 Tried with all the steps above and getting same result. Switched to logcat and saw AndroidOrchestration failed error having below errors
e/androidx test orchestrator: fatal exception when setting up
attempt to invoke virtual method 'android.content.context android.app.instrumentation.getcontext()' on a null object reference.
Is it my device related issue?
Have you tried with fresh emulator?
Created an emulator and tried running tests. This error comes - (No tests were found). I tried Invalidating cache restart and clean rebuild.
Did you cloning the repo again?
Will try this and check if the tests are working.
@dipu989 Can you try installing the app and then running the Espresso tests.
@anandwana001 I tried cloning again and the issue is still there. @FareesHussain I installed the app on my device and tried running tests on it and it failed. I am attaching a gif for reference -
Tried turning off the animations as well but didn't help.
@dipu989 I'm not sure how to fix this. Can you try running any other Espresso tests?
@FareesHussain Same issue with other tests. Do we have to enable/disable any feature in developer mode for these Espresso tests to run?
@FareesHussain Same issue with other tests. Do we have to enable/disable any feature in developer mode for these Espresso tests to run?
No, there is no such option.
@FareesHussain @anandwana001 Tried a workaround from StackOverflow where it was suggested to create an emulator with API less than equal to 28. Did the same and espresso tests are now running successfully. It was not running on an emulator with API level 30 but worked on 28. So should I run the tests after refactor on the new emulator (API 28) itself?
@FareesHussain @anandwana001 Tried a workaround from StackOverflow where it was suggested to create an emulator with API less than equal to 28. Did the same and espresso tests are now running successfully. It was not running on an emulator with API level 30 but worked on 28. So should I run the tests after refactor on the new emulator (API 28) itself?
That's great. I haven't tested running the app or Espresso on API 30. But it is not recommended to use API 30 as the targetSdkVersion is 29 and this might be causing the issue here. https://github.com/oppia/oppia-android/blob/0213cdf50c3abcd39ef588fb5560242e391f0ecc/app/build.gradle#L14
We have local tests under the app module test folder that only run on Robolectric. Now that we have the RunOn annotation, we should prefer keeping all tests under app module's sharedTest folder & instead use the RunOn animation. This issue is tracking: