java - java.lang.IllegalStateException:单元测试期间正在关闭
问题描述
最近,我的一些测试开始失败,但有以下例外:
[Robolectric] tests.integration.TourQueryHandlerTest.testLinkedEmployeeAccompanyingNurse: sdk=25; resources=legacy
[Robolectric] NOTICE: legacy resources mode is deprecated; see http://robolectric.org/migrating/#migrating-to-40
java.lang.IllegalStateException: Shutdown in progress
at java.lang.ApplicationShutdownHooks.add(ApplicationShutdownHooks.java:66)
at java.lang.Runtime.addShutdownHook(Runtime.java:211)
at org.robolectric.util.TempDirectory.<init>(TempDirectory.java:23)
at org.robolectric.android.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:90)
at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:377)
at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:252)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:130)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:42)
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.robolectric.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:84)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
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 com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
在撰写本文时,它似乎只发生在 robolectric 测试中,但并非所有测试都发生,当然也不会同时发生。
我尝试使用我们最好的朋友 Google 进行调查,但到目前为止我还没有找到任何特定于 Android Studio 或 robolectric 的结果
我找到了这个: https ://developer.ibm.com/answers/questions/308650/why-is-the-jvm-failing-to-start-with-javalangilleg/ 它似乎与在已经调用 System.exit() 的进程上添加关闭挂钩;
我正在研究它,但有时测试通过,有时却没有,这很奇怪。
解决方案
推荐阅读
- android - 在真实设备上安装我的项目 apk 失败(android 10)
- automated-tests - 运行 botium 测试时,Dialogflow 后续意图无法正确解析
- css - Css Flex/开始结束/对齐3个组件
- javascript - React-Redux:mapStateToProps 内部的逻辑不会导致重新渲染
- servicestack - ServiceStack /types/csharp 在 v5.7 中生成无效的属性签名
- html - CSS静态文件未在Django中加载
- python - python根据另一个字符串变量创建字符串变量(包含)
- mongodb - mongodb 查询不适用于 Atlas 中的集合
- python - Spacy NER - 训练仅具有实体集合的模型
- python-3.x - 我有什么遗漏吗,代码在 1/3 的数据上不起作用,在 2/3 上它可以正常工作?