ActivityScenario "close()" doesn't work as expected
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- java
- 领域
- mobile-dev, testing
调研方向
先从 ActivityScenario.close() 以及堆栈跟踪位置 ActivityScenario.java:416、:449 和 :684 开始,然后使用 ActivityScenario.launch 和 @After 重现 instrumented test。当 close() 在没有报告的 AssertionError 的情况下达到 DESTROYED 时,即视为完成;该 issue 未提供公共 repository 或指定名称的测试文件。
由索引模型根据 Issue 内容生成。
描述
Description
I'm running an instrumented test using ActivityScenario, so I launch the test, and after the test finishes, I call the method close() of the ActivityScenario.
Then, I received the following error:
java.lang.AssertionError: Activity never becomes requested state "[DESTROYED]" (last
lifecycle transition = "RESUMED")
at androidx.test.core.app.ActivityScenario.waitForActivityToBecomeAnyOf(ActivityScenario.java:449)
at androidx.test.core.app.ActivityScenario.moveToState(ActivityScenario.java:684)
at androidx.test.core.app.ActivityScenario.close(ActivityScenario.java:416)
at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:59)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
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:67)
at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:58)
at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:446)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2218)
I don't know exactly why, but every time that I move the scenario to state DESTROYED the test crashes with the exception above.
When I remove the method "close" calling, the test starts to work as expected.
Steps to Reproduce
- Create an instrumented test for an Activity
- Starts the test using the method "ActivityScenario.launch"
- Closes the scenario using an "@After" JUnit annotation
- The crash will happen
Some libraries used:
- Mockk
- An abstraction of MockWebServer
Expected Results
- Test pass without problems
Actual Results
- Test crashing when calling
closemethod.
AndroidX Test and Android OS Versions
MacBook Pro Apple M1 Pro
OS: Ventura 13.5
JDK version: java 17.0.8
Gradle version: 8.5
AGP: 8.2.1
AndroidX core library version: 1.5.0
Emulator: Pixel 4 API 33
Link to a public git repo demonstrating the problem:
- 主要语言
- Java
- 星标
- 1.2k
- 派生
- 343
- 平均合并
- 1 天 18 小时
- 30 天内合并 PR
- 16
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
android/android-test 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 62/100
android/android-test#681 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 52/100
android/android-test#2544 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 10/100
android/android-test#2541 · 1 条评论 ·
维护者通常 1 天内回复
-
ξεκσνδξδ未关闭
难度 5/5 一周以上 新手友好度 1/100
android/android-test#2499 ·
维护者通常 1 天内回复
-
ησξξσ未关闭
难度 5/5 一周以上 新手友好度 1/100
android/android-test#2498 ·
维护者通常 1 天内回复
查看 android/android-test 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 69/100
paulpacifico/shutter-encoder#485 ·
-
ci reactjs typescript web
难度 2/5 1-3 小时 新手友好度 80/100
mhnuk2007/finsim#175 · 1 条评论 ·
维护者通常 1 天内回复
-
device-results
难度 2/5 1-3 小时 新手友好度 66/100
RamazanKara/nightjar#205 · 2 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复