用下面的代码,测试中没有我想的顺序执行。 test_homescreen是test_splashscreen之前执行。
我想指定要进行的测试,它们的执行顺序。 我相信我需要创建一个测试程序,但我不知道如何实现这一点。
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 -如何管理测试用例的执行顺序?