pedrovgs/Shot

-Precord param not working on api 28+

Open

#246 opened on Jul 28, 2021

 (11 comments) (1 reaction) (0 assignees)Kotlin (111 forks)github user discovery
bughelp wanted

Repository metrics

Stars
 (1,208 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Expected behaviour

Screenshots are successfully generated for cases declared in the sample app

@Test
fun showsAnySuperHero() {
    val superHero = givenASuperHero()
    val holder = givenASuperHeroViewHolder()
    holder.render(superHero)
    compareScreenshot(holder)
}

Actual behaviour

Test completes successfully, but screenshots folder is empty and no errors are generated

Steps to reproduce

Open shot-consumer-flavors Create new avd 28+ Run executeScreenshotTests with following params -Pandroid.testInstrumentationRunnerArguments.class=com.karumi.ui.view.SuperHeroViewHolderTest -Precord

Check the "screenshots" folder when execution is finished

Version of the library

5.11.0 but it also doesn't work in lower versions Tested on api 28+

Possible solution

I think this is happens because of restrictions on non-SDK interfaces (API 28+) So, when I executed the following command, everything works fine

Android 9 (API level 28)
adb shell settings put global hidden_api_policy_pre_p_apps 1
adb shell settings put global hidden_api_policy_p_apps 1
Android 10 (API level 29) or higher
adb shell settings put global hidden_api_policy 1

@pedrovgs How about adding this info to the docs, because I spent a lot of time to launch this type of tests?

Contributor guide