allure-framework / allure-kotlin

Allure integrations for test frameworks targeting Kotlin and Java with 1.6 source compatibility.
Apache License 2.0
57 stars 21 forks source link

The incorrect behavior is in case of granting permissions with AllureAndroidJUnitRunner for app with targetSDK 30 and ran on sdk 29 #50

Closed SergKhram closed 3 years ago

SergKhram commented 3 years ago

I'm submitting a ...

[ ✓] bug report [ ] feature request [ ] support request => Please do not submit support request here, see note at the top of this template.

What is the current behavior?

The error is on granting : Security exception: Package ...android.debug has not requested permission android.permission.WRITE_EXTERNAL_STORAGE

java.lang.SecurityException: Package ....android.debug has not requested permission android.permission.WRITE_EXTERNAL_STORAGE at com.android.server.pm.permission.BasePermission.enforceDeclaredUsedAndRuntimeOrDevelopment(BasePermission.java:425) at com.android.server.pm.permission.PermissionManagerService.grantRuntimePermission(PermissionManagerService.java:2096) at com.android.server.pm.permission.PermissionManagerService.access$900(PermissionManagerService.java:120) at com.android.server.pm.permission.PermissionManagerService$PermissionManagerServiceInternalImpl.grantRuntimePermission(PermissionManagerService.java:2999) at com.android.server.pm.PackageManagerService.grantRuntimePermission(PackageManagerService.java:5734) at com.android.server.pm.PackageManagerShellCommand.runGrantRevokePermission(PackageManagerShellCommand.java:1955) at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:230) at android.os.ShellCommand.exec(ShellCommand.java:104) at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:21729) at android.os.Binder.shellCommand(Binder.java:881) at android.os.Binder.onTransact(Binder.java:765) at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4860) at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4014) at android.os.Binder.execTransactInternal(Binder.java:1021) at android.os.Binder.execTransact(Binder.java:994)

and as the result : 1) Fatal exception when running tests junit.framework.AssertionFailedError: Failed to grant permissions, see logcat for details at junit.framework.Assert.fail(Assert.java:50) at androidx.test.runner.permission.PermissionRequester.requestPermissions(PermissionRequester.java:111) at io.qameta.allure.android.internal.TestUtilsKt.requestExternalStoragePermissions(TestUtils.kt:28) at io.qameta.allure.android.listeners.ExternalStoragePermissionsListener.testRunStarted(ExternalStoragePermissionsListener.kt:9) at org.junit.runner.notification.SynchronizedRunListener.testRunStarted(SynchronizedRunListener.java:35) at org.junit.runner.notification.RunNotifier$1.notifyListener(RunNotifier.java:91) at org.junit.runner.notification.RunNotifier$SafeNotifier.run(RunNotifier.java:72) at org.junit.runner.notification.RunNotifier.fireTestRunStarted(RunNotifier.java:88) at org.junit.runner.JUnitCore.run(JUnitCore.java:136) at org.junit.runner.JUnitCore.run(JUnitCore.java:115) at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56) at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:395) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2189)

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

build_versions = [ target_sdk: 30, build_tools: "30", min_sdk: 21 ] emulator with sdk 29 Espresso/Kaspresso test without debug/AndroidManifest granting permissions

What is the expected behavior?

There are no errors

What is the motivation / use case for changing the behavior?

The motivation is to have a possibility to grant permissions in runtime

Please tell us about your environment:

io.qameta.allure:allure-kotlin-model:2.2.0 io.qameta.allure:allure-kotlin-commons:2.2.0 io.qameta.allure:allure-kotlin-junit4:2.2.0 io.qameta.allure:allure-kotlin-android:2.2.0 | Allure version | 2.2.0 | | Test framework | junit@4.13.1 | | Allure integration | allure-kotlin-android@2.2.0 |