您的位置:首页 > 移动开发

eclipse通过Remote Java Application调试Uiautomator的方法

2015-08-22 14:37 483 查看
上一篇文章将到如何从eclipse中直接启动UiAutomator的脚本,但是在写脚本的时候,之前一直是使用打log的方法,最近遇到逻辑比较复杂的一些情况,感觉打log很费劲,于是找了找网上有没有UiAutomator的调试方法,果然在stackoverflow是有的,就是写得没那么清晰,结合前面一篇文章《从eclipse运行UiAutomator的方法,告别cmd》,在这个基础上,配置远程调试器,打上断点,就能对log
say bye~了。具体做法如下:

1、配置调试器



2、运行脚本Run as --> Java Application,如果是使用Eclipse直接启用的方式,记得要把isDebug的属性设置成true(不清楚的可以看一看之前的一篇文章《从eclipse运行UiAutomator的方法,告别cmd》),如果是使用cmd命令启用脚本的,应该加上"
-e debug true",本示例采用第一种方法启动脚本,脚本如下:

package com.travel.testcase;

import java.io.IOException;
import java.util.ArrayList;

import android.R.integer;

public class CXQUiautomatorTestCase extends UiAutomatorTestCase {
public static void main(String[] args) throws IOException {
RunTestCase runTestCase=new RunTestCase("CXQUiautomatorTestCase",
"com.travel.testcase.CXQUiautomatorTestCase", "", "1");
runTestCase.setDebug(true);
runTestCase.runUiautomator();

}

@Override
protected void setUp() throws Exception {
// TODO Auto-generated method stub
super.setUp();
}

@Override
protected void tearDown() throws Exception {
// TODO Auto-generated method stub
super.tearDown();
}

@SuppressWarnings("deprecation")
public void testDemo() throws UiObjectNotFoundException {

//...你的用例(打上断点)
}
}


点击运行之后,脚本并不会马上运行,而是会反馈以下信息:



也就是说脚本现在是处于一个WAIT的状态,此时我们再使用远程调试器,点击Run --->Debug Configuration ---->找到你刚才配置的调试器 ---->Debug, 这样就可以成功对脚本进行调试了!

效果如下:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: