robotium命令行启动

来源:互联网 发布:学霸必备软件 编辑:程序博客网 时间:2024/05/20 09:48

命令行启动启动的几种常用类型

                    -r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT),打印的原始结果。收集有用的原始性能数据。
                    -e <NAME> <VALUE>: set argument <NAME> to <VALUE>,设置参数的名字。
                    -p <FILE>: 往外部文件写入数据。
                    -w: 一般为必填,否则无法看到测试结果。


Type 1    Run All Test
        该命令用于执行测试工程下面所有的测试类:
        adb shell am instrument -w com.example.test/android.test.InstrumentationTestRunner
        此处我的测试工程包名为com.example.test。
 
Type 2    Running tests from a specific test case
        如想执行某个测试类中所有测试,你可以使用以下命令:
        adb shell am instrument -w -e class  com.example.test.testA com.example.test/android.test.InstrumentationTestRunner       
        此处我的某一个测试类名为testA。
 
Type 3    Running a specific test by name
        如想执行某个测试类中某一个具体的测试,你可以使用以下命令:
        adb shell am instrument -w -e class com.huawei.mao.test.testA\#testadd4 com.huawei.mao.test/android.test.InstrumentationTestRunner
        此处testadd4为测试类testA中的一个具体的测试。
 
Type 4    Running specific tests by category
       测试可以分为不同的类别,通过使用在这个类别的说明(测试注解)来区分,你可以运行某类测试注解的所有测试。你可以使用以下命令:
        adb shell am instrument -w -e size small com.example.test/android.test.InstrumentationTestRunner
        此处我执行的是包里所有用@SmallTest注解的测试。
 
创建自定义注解
        有时候我们需要执行一些特定的测试,也许这些测试不是固定的。此时我们可以通过一些自定义注解来实现,变更测试后只需要把测试的注解改变一下即可。以下是如何写一个自定义注解:
        package com.example.test;
        public @interface ImportantTest {
        }
        OK,现在我们可以使用命令:adb shell am instrument -w -e annotation ImportantTest \com.example.test/android.test.InstrumentationTestRunner
0 0
原创粉丝点击