java.lang.IllegalStateException:单元测试期间正在关闭

时间:2019-04-15 13:39:29

标签: java android-studio robolectric

最近,我的一些测试突然失败,但出现以下异常:

[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)

在撰写本文时,它似乎只发生在机器人测试中,而不是所有测试,当然也并非同时出现。

我尝试使用我们最好的朋友Google进行调查,但到目前为止,我还没有发现任何针对Android Studio或robolectric的结果

我找到了这个: https://developer.ibm.com/answers/questions/308650/why-is-the-jvm-failing-to-start-with-javalangilleg/ 似乎与在已经调用System.exit();的进程上添加关闭钩子有关。

我正在研究它,但是有时测试通过但有时没有通过,这很奇怪。

0 个答案:

没有答案