小编kui*_*ers的帖子

为什么大型Android活动单元测试失败?

我正在尝试使用许多测试方法为Activity创建单元测试.但是在大约31次测试之后,应用程序被杀死了,因为堆内存不足.

1152 E SurfaceFlinger   createSurface() failed, generateId = -12
1152 W WindowManager    OutOfResourcesException creating surface
1152 I WindowManager    Out of memory for surface!  Looking for leaks...
1152 W WindowManager    No leaked surfaces; killing applicatons!
1152 W ActivityManager  Killing processes Free memory at adjustment 1
Run Code Online (Sandbox Code Playgroud)

我用40个相同的简单测试用例进行了单元测试,以找出问题所在.但感觉GC在测试期间没有足够快的速度来清理内存.

这是我的leakTest测试用例:

package my.app;

import android.os.Debug;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;

public class leakTest extends
        ActivityInstrumentationTestCase2<TestActivityAndroid> {

    String TAG = "leakTest";

    TestActivityAndroid mActivity = null;

    public leakTest() {
        super(TestActivityAndroid.class);
    }

    protected void setUp() throws Exception {
        super.setUp(); …
Run Code Online (Sandbox Code Playgroud)

junit android unit-testing

6
推荐指数
1
解决办法
362
查看次数

标签 统计

android ×1

junit ×1

unit-testing ×1