我是robotium用戶現在切換到濃咖啡誰能告訴我怎麼寫的咖啡使用APK測試,正如我們在robotium做,而不必acccess的代碼,但使用的應用程序的apk。Android Espresso如何使用apk編寫測試?
以及如何訪問咖啡中沒有R.id.viewid的視圖?正如我們在robotium做
solo.getview("viewidText")
在robotium這是我們如何做到
public class CoreTest extends ActivityInstrumentationTestCase2 {
private Solo solo;
//class name of the app launcher activity
private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "com.rex.binderapps.RecorderActivity";
private static Class<?> launcherActivityClass;
static {
try {
launcherActivityClass = Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
@SuppressWarnings("unchecked")
public CoreRecordingTest() throws ClassNotFoundException {
super(launcherActivityClass);
}
public void setUp() throws Exception {
super.setUp();
solo = new Solo(getInstrumentation());
Test.setup(this);
getActivity();
}
@Override
public void tearDown() throws Exception {
solo.finishOpenedActivities();
super.tearDown();
}
...
在咖啡
@RunWith(AndroidJUnit4.class)
public class MainActivityTest {
// RecorderActivity is not accessible
@Rule public final ActivityRule<RecorderActivity> main = new ActivityRule<>(RecorderActivity.class);
@Test
public void launchMain(){
}
}
如何指定類名?
UI Automator的將是一個更適合這種免費源的集成測試的,恕我直言。 – CommonsWare
@CommonsWare感謝,我們有複雜的功能測試,用ui automator做這些不可行。我們有兩個獨立的項目,所以現在我們不能直接將濃縮咖啡測試集成到主項目中,所以找到了使用apk編寫測試的解決方法,一旦測試項目準備就緒,我們將與主項目集成。 –