Launching app and executing some test cases with Robotium

0
0

I am new to Robotium and tried to execute following code to launch an app and perform some functions.

An example would be, launch messaging app on android emulator and send a text message “Hi” to a user “test”.

     package com.example.android.test;
import com.example.android.NewUserActivity;
import com.jayway.android.robotium.solo.Solo;
import android.test.ActivityInstrumentationTestCase2;
public class NewUserActivityTest extends ActivityInstrumentationTestCase2<NewUserActivity> {
private Solo solo;
public NewUserActivityTest() {
super("com.example.android", NewUserActivity.class);
}
public void setUp() throws Exception {
super.setUp();
solo = new Solo(getInstrumentation(), getActivity());
}
@Override
public void tearDown() throws Exception {
try {
solo.finalize();
} catch (Throwable e) {
e.printStackTrace();
}
getActivity().finish();
super.tearDown();
}
public void sms() throws Exception{
assertTrue(solo.searchText("Messaging"));
solo.clickOnText("Messaging");
assertTrue(solo.searchText("New message"));
solo.clickOnButton("New message");
solo.enterText(0, "Test");
solo.enterText(1, "Hi");
}
}

With this code, Eclipse runs the test cases but I don’t see it on emulator. I understand the package here is a dummy one, I want to know If I am doing it wrong?

  • You must to post comments
1
0

Test methods that you want to be executed must have the prefix “test”, e.g. “testSms”.

  • 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