ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
上一篇文章中说了如何在windows搭建cts以及运行cts进行测试。这篇文章来讲讲如何在eclipse中配置源码,进行debug调试。 # 下载 cts源码地址:[https://android.googlesource.com/platform/cts](https://android.googlesource.com/platform/cts) 可以使用git下载到本地。 # 目录结构 ![](https://box.kancloud.cn/2016-01-09_56911dc5002c2.jpg) 在tools文件夹下有一个项目:tradefed-host ![](https://box.kancloud.cn/2016-01-09_56911dc524d48.jpg) 将这个项目到入到eclipse中。 ![](https://box.kancloud.cn/2016-01-09_56911dc54ba73.jpg) 出现感叹号的原因是由于jar包引用出现了问题。 ![](https://box.kancloud.cn/2016-01-09_56911dc57328b.jpg) 所以我们要引用到本地的jar包。在网上搜索以下几个jar包,我把我本地的也上传了。 [ddmlib-prebuilt.jar](http://download.csdn.net/detail/qhshiniba/8049201),[tradefed-prebuilt.jar](http://download.csdn.net/detail/qhshiniba/8049365),[hosttestlib.jar](http://download.csdn.net/detail/qhshiniba/8049385),[javalib-deviceinfo.jar](http://download.csdn.net/detail/qhshiniba/8049395),[javalib-deviceutil.jar](http://download.csdn.net/detail/qhshiniba/8049403) 导入后,感叹号消失。 ![](https://box.kancloud.cn/2016-01-09_56911dc5cb013.jpg) 对于DeviceInfoResult.java的错误 ![](https://box.kancloud.cn/2016-01-09_56911dc5e5d23.jpg) 将其删除或者改为DeviceInfoConstants.OPEN_GL_ES_VERSION都可以,不影响。 # 源码运行 找到项目的入口类CtsConsole.java,右键 ![](https://box.kancloud.cn/2016-01-09_56911dc6290f3.jpg) 点击Debug Configurations...,找到Java Application想,选择参数Arguments一栏。 ![](https://box.kancloud.cn/2016-01-09_56911dc682357.jpg) 配置如下: ![](https://box.kancloud.cn/2016-01-09_56911dc6b85ee.jpg) Program arguments配置的就是代表你在之前cts命令行下输入run cts --plan Signature是一个意思。 ![](https://box.kancloud.cn/2016-01-09_56911dc6dcaaa.jpg) 这次我们选用Signature这个计划,上一篇文章用Java计划等了3个小时才执行完.这次换个简单的。 这个时候右键CtsConsole.java运行。console会显示如下: ![](https://box.kancloud.cn/2016-01-09_56911dc7008da.jpg) 和在命令行下显示的一样,区别的地方是我们是用源码运行的。 # 调试 上面已经可以用源码运行了,下面开始使用debug模式调试源码。 在CtsConsole.java的main方法上打上断点。 ![](https://box.kancloud.cn/2016-01-09_56911dc72f09e.jpg) 右键debug模式启动。 ![](https://box.kancloud.cn/2016-01-09_56911dc74eaea.jpg) 点击yes进入debug模式。 ![](https://box.kancloud.cn/2016-01-09_56911dc773339.jpg) 至此我们已经开始了debug调试。后面几篇文章一步一步的用debug的模式认识cts框架的机制