如何从命令行启动Android测试单元 [英] How to start Android test unit from command line
本文介绍了如何从命令行启动Android测试单元的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为我的程序编写自动测试。我已经完成了在Android上的编写。但是,现在我想编写一个脚本来从命令行adb shell运行它。你知道怎么做吗?当我测试程序的许多组件时,从脚本运行它可以节省很多精力。
Im writing automatic test for my program. I have completed writing it on Android. However, now I want to write a script to run it from command line adb shell. Do you know how to do it? As I test many components of my program, running it from script will save lots of my effort.
谢谢。
这是我的清单文件:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wsandroid.test"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<uses-library android:name="android.test.runner" />
</application>
<uses-sdk android:minSdkVersion="3" />
<instrumentation android:targetPackage="com.wsandroid" android:name="android.test.InstrumentationTestRunner" />
谢谢
推荐答案
请参见 Android开发人员文档,其中有一组命令可以运行一个单元测试:
See the Android developer documentation, there is a set of commands to run one single unit test:
$ adb shell am instrument -w \
-e class com.android.samples.AllTests \
com.android.samples.tests/android.test.InstrumentationTestRunner
您将在上述命令行序列中的类标签所在的位置指定类名。
You will specify your class-name where the class label is in the above command-line sequence.
这篇关于如何从命令行启动Android测试单元的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文