Automate multiple activities using Robotium solo in a single test case?

2,651 views
Skip to first unread message

shivang....@gmail.com

unread,
Aug 11, 2011, 2:14:49 AM8/11/11
to Robotium Developers
I have an application where there are 3 activities and I want to write
a test case to do the testing of all the three activities. I have a
service with which these activities interact. I can't quite figure out
how this should be done. Any example for testing multiple activities
in one test case would do me good. Thanks. Or should I adopt a
different approach?

Yahor Paulavets

unread,
Aug 11, 2011, 2:23:44 AM8/11/11
to robotium-...@googlegroups.com
You can test any number of activities within one application.


--
You received this message because you are subscribed to the Google Groups "Robotium Developers" group.
To post to this group, send email to robotium-...@googlegroups.com.
To unsubscribe from this group, send email to robotium-develo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/robotium-developers?hl=en.


shivang....@gmail.com

unread,
Aug 11, 2011, 2:34:47 AM8/11/11
to Robotium Developers
Could you please provide a simple example? i am a newbie.

obulreddy at

unread,
Aug 11, 2011, 3:00:51 AM8/11/11
to robotium-...@googlegroups.com
Hi,

By the way of writing script only you can move to one activity to another activity.

For example,
// Assume that startup activity is your home cativity having 1 button
solo.clickonbutton(btn1); 
// Assume that after clicking button 1 in first activity, you can move to another activity having button2
solo.clickonbutton(btn2);
// Assume that after clicking button 2 in second activity, you can move to another activity having button3
solo.clickonbutton(btn3);

Solo class will take care about internally for multiple activities....

Thanks and Regards,
a.t.obulreddy,
Agile Test Engineer, 

On Thu, Aug 11, 2011 at 12:04 PM, shivang....@gmail.com <shivang....@gmail.com> wrote:
Could you please provide a simple example? i am a newbie.

--

shivang....@gmail.com

unread,
Aug 11, 2011, 3:38:27 AM8/11/11
to Robotium Developers
Do we have to handle the Service Binding separately? How should a test
case be written? Simply as a user would use my application right?. Let
me clarify my question. Suppose I have one activity which starts and
does nothing but start a service. This service in turn starts the
Clicking on this button I will send some information to the service
and then a new Activity should get launched. Now inside this activity
by giving some KeyCode Events and pressing the Ok button the 3rd
activity should get launched. I need This to happen inside my test
case. Let me post the code that I have written already

public class StartToEndTest extends InstrumentationTestCase{

private Solo solo;
private Instrumentation mInstrumentation;
private Context mTargetContext;

public void testAutomation(){

mInstrumentation = getInstrumentation();
solo = new Solo(mInstrumentation);
mTargetContext = mInstrumentation.getTargetContext();

//Start 1st activity
Intent intent = new
Intent(mTargetContext,FirstActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mInstrumentation.startActivitySync(intent);

//Wait for the 2nd activity and check not null
solo.waitForActivity(SecondActivity.class.getName());
solo.assertCurrentActivity("Failure to start Second
Activity", SecondActivity.class);

//Sleep for some time. No particular reason.
solo.sleep(10000);
//Added these 2 if statements to ensure correct button is
being detected.
if(solo.searchButton("Reporting for Duty", true)){
Button btn = solo.getButton("Reporting for Duty");
if(btn.isClickable()){
solo.clickOnButton("Reporting for Duty");
}
}

//Wait for 3rd activity
solo.waitForActivity(ThirdActivity.class.getName());
solo.assertCurrentActivity("Failure", ThirdActivity.class);


}

}

shivang....@gmail.com

unread,
Aug 11, 2011, 3:48:41 AM8/11/11
to Robotium Developers
Missing line in my reply -> "This service in turn starts 2nd activity
which has a button."
Reply all
Reply to author
Forward
0 new messages