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

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

Open Chaner2015 opened 3 years ago

Chaner2015 commented 3 years ago

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 junit@4.12
Allure integration allure-kotlin-android@2.1.2
aljohnston112 commented 2 years ago

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

aljohnston112 commented 2 years ago

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