下面的代码,测试不按照我想要的顺序执行。在test_splashscreen之前执行test_homescreen。如何创建一个robotium测试套件?
我想指定要运行的测试及其执行顺序。 我相信我需要创建一个测试套件,但我不知道如何实现该套件。只有
package com.myapp.test;
import com.jayway.android.robotium.solo.Solo;
import android.test.ActivityInstrumentationTestCase2;
import com.myapp.R;
public class myTest extends ActivityInstrumentationTestCase2{
private static final String TARGET_PACKAGE_ID="com.myapp.test";
private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME="com.myapp.gui.SplashScreen";
private static Class launcherActivityClass;
static{
try
{
launcherActivityClass=Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
} catch (ClassNotFoundException e){
throw new RuntimeException(e);
}
}
public myTest()throws ClassNotFoundException{
super(TARGET_PACKAGE_ID,launcherActivityClass);
}
private Solo solo;
@Override
protected void setUp() throws Exception{
solo = new Solo(getInstrumentation(),getActivity());
}
public void test_splashscreen() throws InterruptedException {
TextView splashAppVersion = (TextView) solo.getView(R.id.AppVersion);
assertTrue(splashAppVersion.isShown());
}
public void test_homescreen() throws InterruptedException {
ListView lv = (ListView) solo.getView(R.id.List);
assertTrue(lv.isShown());
}
@Override
public void tearDown() throws Exception {
try {
solo.finishOpenedActivities();
} catch (Throwable e) {
e.printStackTrace();
}
super.tearDown();
}
}
执行第一test_splashscreen(),然后test_homescreen()
执行test_homescreen()
这个职位似乎是接近想什么,但我我一直无法使用它。太通用了。 Android Robotium - How to manage the execution order of testcases?
我更关心如何实现一个测试套件,列出特定的测试及其执行顺序。否则,做一个测试套件有什么意义? – Franck