Reputation: 23483
I have a Robotium test suite that I am trying to run and for some reason it only runs the first test, then freezes after that. I have let the program run for a few minutes, but it just sits there saying "test running". Here is my code:
import com.jayway.android.robotium.solo.Solo;
import android.test.ActivityInstrumentationTestCase2;
@SuppressWarnings("unchecked")
public class ODPRobotiumTest extends ActivityInstrumentationTestCase2 {
private static final String TARGET_PACKAGE_ID = "com.gravitymobile.app.hornbill";
private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "com.vzw.odp.LaunchActivity";
private static Class<?>launcherActivityClass;
static{
try{
launcherActivityClass = Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
} catch (ClassNotFoundException e){
throw new RuntimeException(e);
}
}
@SuppressWarnings({ "unchecked", "deprecation" })
public ODPRobotiumTest() throws ClassNotFoundException{
super(TARGET_PACKAGE_ID, launcherActivityClass);
}
private Solo solo;
@Override
protected void setUp() throws Exception{
solo = new Solo(getInstrumentation(), getActivity());
}
public void testLine1(){
solo.searchText("Easy to Find");
}
public void testLine2(){
solo.searchText("Hassle-Free");
}
public void testLine3(){
solo.searchText("Trust");
}
public void testLine4(){
solo.searchText("Verizon Curated Wallpaper");
}
public void testLine5(){
solo.searchText("Taco's");
}
@Override
public void tearDown() throws Exception{
try{
solo.finalize();
}catch(Throwable e){
e.printStackTrace();
}
getActivity().finish();
super.tearDown();
}
}
Any help would be great. Thanks!
Here is the Junit:
Upvotes: 2
Views: 1157
Reputation: 23483
So I found the answer: You have to include solo.finishOpenedActivities();
in the tearDown() method. This will "finish" the test and then begin the new test! Whew!
Thank you to everyone who offered help!
Upvotes: 1
Reputation: 13097
You need to annotate the tests to run as part of the suite. Try:
@Smoke
public void testLine1(){
solo.searchText("Easy to Find");
}
Keep in mind that you aren't asserting anything in these tests, so they aren't very useful yet. You'll need to add assertions to check that your code is functioning properly
Upvotes: 1
Reputation: 76458
You don't have any assertions in your tests (although I wouldn't think this would be the problem) What doe the Junit panel show when they're running?
or try:
public void testLine1(){
assertTrue(solo.searchText("Easy to Find"));
}
Upvotes: 1