Skip to content
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

--clear-app-data interferes with permissions #562

Open
ssaqua opened this issue May 2, 2019 · 2 comments
Open

--clear-app-data interferes with permissions #562

ssaqua opened this issue May 2, 2019 · 2 comments

Comments

@ssaqua
Copy link

ssaqua commented May 2, 2019

The --clear-app-data option added in #535 interferes with any permissions setup by Spoon such as read/write external storage or those granted through --grant-all. Since these permissions are not granted again after the pm clear command, functionality that you might reasonably expect to work (screenshots, code coverage, files) will no longer work unless granted again in some other way.

@stephane-ducornet-tagheuer
Copy link

stephane-ducornet-tagheuer commented Dec 16, 2019

Hello,
is there a solution or a workaround ?

@stephane-ducornet-tagheuer
Copy link

stephane-ducornet-tagheuer commented Dec 16, 2019

Finally, I found the solution:

  1. Set the clearAppDataBeforeEachTest in Gradle:

spoon {
...
clearAppDataBeforeEachTest = true
}

  1. Set permissions into the Maniest

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
...
  1. And add permissions into the test (Kotlin):

class PurchaseTests : BaseTest() {

companion object {
    @ClassRule
    @JvmField
    val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(
        android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
        android.Manifest.permission.READ_EXTERNAL_STORAGE
    )
}

@Test
fun userShouldAddItemToCart() {
    ...
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants