我有一個Android應用程序,我試圖與詹金斯建立。我已經使用Android模擬器插件啓動了模擬器,並使用gradle腳本構建了該項目,但我無法運行使用AndroidJUnitRunner編寫的簡單測試。詹金斯和運行AndroidJUnitRunner儀器測試
從詹金斯我看起來就像這樣......
+ adb shell pm list instrumentation
instrumentation:com.android.emulator.connectivity.test/android.test.InstrumentationTestRunner (target=com.android.emulator.connectivity.test)
instrumentation:com.android.emulator.gps.test/android.test.InstrumentationTestRunner (target=com.android.emulator.gps.test)
instrumentation:com.android.smoketest.tests/com.android.smoketest.SmokeTestRunner (target=com.android.smoketest)
instrumentation:com.android.smoketest.tests/android.test.InstrumentationTestRunner (target=com.android.smoketest)
instrumentation:com.example.android.apis/.app.LocalSampleInstrumentation (target=com.example.android.apis)
[Short Sounds] $ /bin/sh -xe /tmp/hudson7415767398022941631.sh
+ adb shell am instrument -w com.sloths.speedy.shortsounds/android.support.test.runner.AndroidJUnitRunner
INSTRUMENTATION_STATUS: id=ActivityManagerService
INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{com.sloths.speedy.shortsounds/android.support.test.runner.AndroidJUnitRunner}
INSTRUMENTATION_STATUS_CODE: -1
android.util.AndroidException: INSTRUMENTATION_FAILED: com.sloths.speedy.shortsounds/android.support.test.runner.AndroidJUnitRunner
正如你可以看到我列出通過shell命令adb的儀器。 AndroidJUnitRunner不在哪裏可以在列表中找到。我是半正面的,應該在那裏才能正常工作。
我已經添加在的build.gradle文件中的相應配置標籤... IE瀏覽器...
defaultConfig {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
我還添加了這些依賴關係。
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
...
androidTestCompile 'com.android.support.test:runner:0.2'
// Set this dependency to use JUnit 4 rules
androidTestCompile 'com.android.support.test:rules:0.2'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'
}
並在萬一它的幫助是我試圖運行的測試。這只是一個簡單的單元測試,我想失敗。
import android.support.test.runner.AndroidJUnit4;
import android.test.ActivityInstrumentationTestCase2;
import com.sloths.speedy.shortsounds.view.MainActivity;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class InitialFailingTest extends ActivityInstrumentationTestCase2<MainActivity> {
public InitialFailingTest() {
super(MainActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
}
@Test
public void initialFailingTestForJenkins() {
assertTrue(false);
}
}
我怎樣才能讓詹金斯真正運行我的單元測試?任何幫助是極大的讚賞。
酷我會試試看! – Sigotron
是的工作!謝謝! – Sigotron
很高興幫助隊友:) – WenChao