我使用Espresso运行了大约200次测试。其中大多数是大型测试。虽然测试正在运行,但应用程序崩溃并在日志中显示,
测试未能完成。原因:'仪表运行因“进程崩溃”而失败。>
我认为它是由于OutOfMemory问题。在拆解方法中是否有可用于清除内存的修复程序,以便我们可以在每次测试完成后清除内存?或者还有其他工作来解决这个问题吗?我尝试过使用android:largeHeap =" true"在测试清单文件中。但它不起作用。这是完整的日志,
java.lang.OutOfMemoryError: Failed to allocate a 50452 byte allocation with 43158 free bytes and 42KB until OOM
at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:95)
at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:163)
at java.lang.StringBuilder.append(StringBuilder.java:288)
at java.lang.StringBuilder.append(StringBuilder.java:44)
at android.support.test.espresso.core.deps.guava.base.Joiner.appendTo(Joiner.java:111)
at android.support.test.espresso.core.deps.guava.base.Joiner.appendTo(Joiner.java:152)
at android.support.test.espresso.core.deps.guava.base.Joiner.appendTo(Joiner.java:140)
at android.support.test.espresso.util.HumanReadables.getViewHierarchyErrorMessage(HumanReadables.java:76)
at android.support.test.espresso.NoMatchingViewException.getErrorMessage(NoMatchingViewException.java:87)
at android.support.test.espresso.NoMatchingViewException.<init>(NoMatchingViewException.java:59)
at android.support.test.espresso.NoMatchingViewException.<init>(NoMatchingViewException.java:46)
at android.support.test.espresso.NoMatchingViewException$Builder.build(NoMatchingViewException.java:145)
at android.support.test.espresso.base.ViewFinderImpl.getView(ViewFinderImpl.java:95)
at android.support.test.espresso.ViewInteraction$1.run(ViewInteraction.java:120)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
答案 0 :(得分:1)
我可能错了,但是我可以看到你第一次拥有NoMatchingViewException
,这意味着你的测试中出现了问题并找不到预期的视图,然后当Espresso尝试创建错误信息时你收到了OOM错误。所以似乎根本原因是NoMatchingViewException
。所以也许你应该先解决它。