jenkins で試験を、な前提として
$ ./gradlew connectedInstrumentTest
で試験が実行されるようになっていること、という前提がある模様。以下で昨日作成したソレについて確認をしてみるなど。
$ ./gradlew tasks --all |lv
以下が出力されていることを確認。
helloworld:connectedInstrumentTest - Installs and runs the tests for Build ‘debug’ on connected devices. [helloworld:assembleDebug, helloworld:assembleDebugTest]
assembleDebug と assembleDebugTest というタスクもあることを確認。
出力を見るに
- processDebugManifest
- prodessDebugResources
- prodessDebugTestJavaRes
- prodessDebugTestManifest
- prodessDebugTestResoures
あたりが、なのかどうか。とは言えとりあえず connectedInstrumentTest なターゲットで試験が実行されるようになってれば jenkins で云々できる模様。
試しに実行してみた
$ ./gradlew connectedInstrumentTest
なんかちゃんと動いてるな。fail するけど。つうかこれ、実機外すとどうなるのかなということで試してみると当り前に駄目でした。
がしかし、つうことはこの時点で jenkins 使って云々が可能、ってことになるのか。
もう少し
あと検討が必要なのは
- ContentProvider の mock
- Preferences
- ネットワークの mock
ということでもう少し確認なのかどうか。このあたりはエントリを改めることにしてとりあえずエントリ投入します。
ちなみに
試験の実装は現状以下になってます。
public class ExampleTest extends InstrumentationTestCase {
private MainActivity mCurrentActivity;
Instrumentation mInstrumentation;
private Instrumentation.ActivityMonitor mMonitor;
@Override
protected void setUp() throws Exception {
super.setUp();
mInstrumentation = getInstrumentation();
mMonitor = mInstrumentation.addMonitor(MainActivity.class.getName(), null, false);
mCurrentActivity = (MainActivity)mInstrumentation.waitForMonitorWithTimeout(mMonitor, 5);
}
public void testExample() throws Exception {
TextView textView = (TextView)mCurrentActivity.findViewById(R.id.hello_world);
assertEquals("Hello World!", textView.getText().toString());
}
}
なんとなく UI の確認はできそげなカンジ。