Skip to content

ActivityScenarioRule incompatible with release build type #940

@softartdev

Description

@softartdev

Description

After migrate from deprecated ActivityTestRule to ActivityScenarioRule ui-tests with release build type failed:

java.lang.AssertionError: Activity never becomes requested state "[STARTED, CREATED, DESTROYED, RESUMED]" (last lifecycle transition = "PRE_ON_CREATE")
at androidx.test.core.app.ActivityScenario.waitForActivityToBecomeAnyOf(ActivityScenario.java:338)

Steps to Reproduce

The build type that test against is controlled by the testBuildType flag. Switch between release & debug by setting property from CLI.
Use keeper library for keep test APK sources on minified release build.
Replace all ActivityTestRule with activityScenarioRule.

Actual Results

Bug reproduces on my pet-project's GitHub-Actions CI:
https://github.com/softartdev/NoteDelight/runs/2433814114?check_suite_focus=true#step:7:295
Note that step for debug build type ui-tests was successful:
https://github.com/softartdev/NoteDelight/runs/2433814114?check_suite_focus=true#step:6:1062

Expected Results

Both release & debug build types ui-tests was successful before test-rules update:
https://github.com/softartdev/NoteDelight/runs/2433726325?check_suite_focus=true#step:7:302
https://github.com/softartdev/NoteDelight/runs/2433726325?check_suite_focus=true#step:6:1082
Most test results are flaky, more stable in SDK 26~29 API versions.

AndroidX Test and Android OS Versions

AndroidX Test libs version 1.3.0
targetSdkVersion 30

Link to a public git repo demonstrating the problem:

https://github.com/softartdev/NoteDelight/tree/scenario

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions