8种机械键盘轴体对比
本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选?
connectedAndoidTest 預設會將所有 test 執行在所有連接的 device/emulator 上,若只想執行某些 test 要怎麼做?
connectedAndroidTest 背後其實也是透過 am instrument 搭配 AndroidJUnitRuner 在 device/emulator 上執行測試:am instrument -w [] /
其中 RUNNER_CLASS 通常是 android.support.test.runner.AndroidJUnitRunner。
AndroidJUnitRunner 本身支援許多跟測試篩選 (test filtering) 有關的 flag (-e ),例如要執行特定一個 test 可以用 -e class com.example.FooTest#testFoo。
早期 connectedAndroidTest 不支援從 command line 傳入 instrumentation runner argument (也就是上面的 flag),只能先將 test app 安裝上去,再用 am instrument 執行測試。例如:1
2
3$ ./gradlew installDebugAndroidTest
$ adb shell am instrument -w -e class com.example.FooTest#testFoo
com.example.test/android.support.test.runner.AndroidJUnitRunner
不過 Android Plugin for Gradle 從 1.3.0 版開始支援這項功能:Android plugin for Gradle, revision 1.3.0 (July 2015)
Added support for specifying instrumentation test-runner arguments from the command line. For example:1
2
3
4> ./gradlew connectedCheck
> -Pandroid.testInstrumentationRunnerArguments.size=medium
> -Pandroid.testInstrumentationRunnerArguments.class=TestA,TestB
>
也就是以下面的形式從 command line 提供 runner argument:-Pandroid.testInstrumentationRunnerArguments.=
所上面的例子可以改用:1
2$ ./gradlew connectedAndroidTest
-Pandroid.testInstrumentationRunnerArguments.class=com.example.FooTest#testFoo
AndroidJUnitRunner 還支援其他 case filtering 的條件,包括:-e class com.example.FooTest#testFoo,com.example.BarTest#testBar - 只執行一或多個 test。
-e class com.example.FooTest,com.example.BarTest - 只執行一或多個 class 裡所有的 test。
-e package com.example.foo - 只執行某個 (Java) package 裡所有的 test。
-e annotation com.example.MyAnnotation - 只執行有標示某個 annotation 的 test。
-e notAnnotation com.example.MyAnnotation,com.example.AnotherAnnotation - 排除有標示任一 annotation 的 test。
-e size small | medium | large - 只執行標示有 @SmallTest、@MediumTest 或 @LargeTest 的 test。
至於如何讓 test 只執行在某些 device/emulator 上會在另一篇說明,但這兩者是可以並用的,例如:1
2$ ANDROID_SERIAL=emulator-5554,ABC123DEF ./gradlew connectedAndroidTest
-Pandroid.testInstrumentationRunnerArguments.size=small
只在 emulator-5554 (emulator) 與 ABC123DEF (device) 上執行標示有 @SmallTest 的 test。