Test run failed: Instrumentation run failed due to 'Process crashed.'

本文探讨了在使用Robotium进行应用测试时遇到的常见问题:“Testrunfailed:Instrumentationrunfaileddueto'Processcrashed.'”。文章分析了这一错误产生的原因,并解释了测试工程和被测工程在同一进程中,清除应用数据操作导致测试进程被意外终止,从而引发应用崩溃。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我们在执行robotium时,经常会出现“Test run failed: Instrumentation run failed due to 'Process crashed.'”这个错误。

这是因为测试工程和被测工程在同一个进程,你调用上面的一段代码是清除应用程序的数据,但是清除应用数据过程中会强制kill掉这个应用进程,其实测试进程也被kill了,所以引起crash。


java.lang.AssertionError: Failed to successfully run device tests for com.google.android.gts.location: Instrumentation run failed due to 'Process crashed.' at com.android.tradefed.testtype.junit4.BaseHostJUnit4Test.runDeviceTests(BaseHostJUnit4Test.java:733) at com.android.tradefed.testtype.junit4.BaseHostJUnit4Test.runDeviceTests(BaseHostJUnit4Test.java:486) at com.google.android.gts.location.locationhost.LocationHostTest.runTest(LocationHostTest.java:103) at com.google.android.gts.location.locationhost.LocationHostTest.testGnssSatelliteBlocklist(LocationHostTest.java:90) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:61) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) 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 com.android.tradefed.testtype.DeviceJUnit4ClassRunner.runChild(DeviceJUnit4ClassRunner.java:111) at com.android.tradefed.testtype.DeviceJUnit4ClassRunner.runChild(DeviceJUnit4ClassRunner.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$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 com.android.tradefed.testtype.DeviceJUnit4ClassRunner.run(DeviceJUnit4ClassRunner.java:147) at com.android.tradefed.testtype.junit4.ExceptionThrowingRunnerWrapper.run(ExceptionThrowingRunnerWrapper.java:43) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.android.tradefed.testtype.HostTest.runJUnit4Tests(HostTest.java:765) at com.android.tradefed.testtype.HostTest.runTestClasses(HostTest.java:645) at com.android.tradefed.testtype.HostTest.run(HostTest.java:593) at com.android.compatibility.common.tradefed.testtype.JarHostTest.run(JarHostTest.java:56) at com.android.tradefed.testtype.suite.GranularRetriableTestWrapper.intraModuleRun(GranularRetriableTestWrapper.java:386) at com.android.tradefed.testtype.suite.GranularRetriableTestWrapper.run(GranularRetriableTestWrapper.java:283) at com.android.tradefed.testtype.suite.ModuleDefinition.run(ModuleDefinition.java:626) at com.android.tradefed.testtype.suite.ITestSuite.runSingleModule(ITestSuite.java:1289) at com.android.tradefed.testtype.suite.ITestSuite.run(ITestSuite.java:1056) at com.android.tradefed.invoker.InvocationExecution.runTest(InvocationExecution.java:1457) at com.android.tradefed.invoker.InvocationExecution.runTests(InvocationExecution.java:1232) at com.android.tradefed.invoker.TestInvocation.prepareAndRun(TestInvocation.java:644) at com.android.tradefed.invoker.TestInvocation.performInvocation(TestInvocation.java:291) at com.android.tradefed.invoker.TestInvocation.invoke(TestInvocation.java:1437) at com.android.tradefed.command.CommandScheduler$InvocationThread.run(CommandScheduler.java:692)
最新发布
03-27
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值