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

TestRunner: java.lang.AssertionError: Activity never becomes requested state "[CREATED, DESTROYED, RESUMED, STARTED]" (last lifecycle transition = "PRE_ON_CREATE") #47

Open
Chaner2015 opened this issue Feb 7, 2021 · 2 comments
Labels
type:bug Something isn't working

Comments

@Chaner2015
Copy link

Chaner2015 commented Feb 7, 2021

When I run the test on a device, I get:

Started running tests

W/Settings: Setting always_finish_activities has moved from android.provider.Settings.System to android.provider.Settings.Global, returning read-only value.
E/TestRunner: failed: testxxx(com.example.demo.xxxTest)

    ----- begin exception -----
E/TestRunner: java.lang.AssertionError: Activity never becomes requested state "[CREATED, DESTROYED, RESUMED, STARTED]" (last lifecycle transition = "PRE_ON_CREATE")
        at androidx.test.core.app.ActivityScenario.waitForActivityToBecomeAnyOf(ActivityScenario.java:338)
        at androidx.test.core.app.ActivityScenario.launchInternal(ActivityScenario.java:272)
        at androidx.test.core.app.ActivityScenario.launch(ActivityScenario.java:195)
        at androidx.test.ext.junit.rules.ActivityScenarioRule.lambda$new$0$ActivityScenarioRule(ActivityScenarioRule.java:70)
        at androidx.test.ext.junit.rules.ActivityScenarioRule$$Lambda$0.get(Unknown Source:2)
        at androidx.test.ext.junit.rules.ActivityScenarioRule.before(ActivityScenarioRule.java:103)
        at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:46)
        at io.qameta.allure.android.rules.LogcatRule$apply$1.evaluate(LogcatRule.kt:23)
        at io.qameta.allure.android.rules.ScreenshotRule$apply$1.evaluate(ScreenshotRule.kt:22)
        at org.junit.rules.RunRules.evaluate(RunRules.java:20)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at io.qameta.allure.kotlin.junit4.AllureRunner.run(Runners.kt:10)
        at org.junit.runners.Suite.runChild(Suite.java:128)
        at org.junit.runners.Suite.runChild(Suite.java:27)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
        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:2169)
    ----- end exception -----

my test step:

      adb shell am instrument -w -r    -e debug true -e class 'com.example.demo.Test#testXXXcase' com.demo.test/io.qameta.allure.android.runners.AllureAndroidJUnitRunner  

my environment:

run on vivo V1934A

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
testImplementation 'androidx.test.ext:junit:1.1.1'
//espresso
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test:rules:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.0'
androidTestImplementation 'de.schroepf:android-xml-run-listener:0.4.0'

androidTestImplementation "io.qameta.allure:allure-kotlin-model:2.1.2"
androidTestImplementation "io.qameta.allure:allure-kotlin-commons:2.1.2"
androidTestImplementation "io.qameta.allure:allure-kotlin-junit4:2.1.2"
androidTestImplementation "io.qameta.allure:allure-kotlin-android:2.1.2"
Allure version 2.1.2
Test framework [email protected]
Allure integration [email protected]
@viclovsky viclovsky added the type:bug Something isn't working label Feb 9, 2021
@aljohnston112
Copy link

Can you run unit tests? If so, it might be related to this.
android/android-test#1377
Check the logs for any exceptions that might be covered up by test framework

@aljohnston112
Copy link

Do you have debugImplementation 'androidx.test:core-ktx:1.4.0'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants