Issue
The problem is:
- I run my application. Settings are present and everything is fine.
- I run instrumentation tests (gradle task connectedCheck). Tests not operate with settings (not read, not remove, even don't touch). Test are annotated with
@RunWith(AndroidJUnit4.class)and aren't using activities at all. - I run my app again and I have to specify settings like I reinstalled my app.
I've tried to specify testApplicationId in gradle buildscript:
android {
...
defaultConfig {
...
testApplicationId "something.package"
But it has no effect.
Why it is happening, and how to solve this issue?
Solution
According to the Gradle User-guide:
As mentioned previously, checks requiring a connected device are launched with the anchor task called
connectedCheck. This depends on the taskconnectedDebugAndroidTestand therefore will run it. This task does the following:
- Ensure the app and the test app are built (depending on
assembleDebugandassembleDebugAndroidTest).- Install both apps.
- Run the tests.
- Uninstall both apps.
You can use the regular run-configuration to launch tests instead of connectedCheck:
Answered By - The Dreams Wind

0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.