Robotium Assertion Failing

0
0

When I run a test with Robotium, I use an assertion to verify that there is specific text on the page, but it fails. However, when I run the test without the assertion, the test passes. Why would this be?

Here is my code:

import com.jayway.android.robotium.solo.Solo;
import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.Smoke;
@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());
}
@Smoke
public void testLine1(){
try {
assertTrue
(solo.searchText("Easy to Find")) ;
} catch (Exception e) {
// TODO Auto-generated catch block
e
.printStackTrace();
}
}
@Smoke
public void testLine2(){
try{
solo
.searchText("Hassle-Free");
}catch(Exception e){
e
.printStackTrace();
}
}
@Smoke
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();
}
}

The test in testLine1 is the test that fails. But like I said before, when I don’t use the assertTrue, and just solo.searchTest(“Easy to find”), the test will pass. I don’t understand.

Thanks for any help!

  • You must to post comments
0
0

If you don’t assert anything then your test will pass cause nothing can fail.

Obviously the text you are searching is either missing from the screen, your configuration of the test runner is wrong or you are not even using the correct mechanisms for searching.

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website