In this post I will show you how to automate android application using robotium framework with testdroid recorder.
Testdroid recorder is capture user action , generate reusable android test case into robotium framework. For more detail about Testdroid visit link “click here”
Prerequisites:
1. Start Eclipse and go to Help -> Install New Software
2. Click Add button; enter to field asking you a site to work with.
3. Fill in “Testdroid plug-in” for the Name
4. For the Location provide URL to Testdroid repository: http://www.testdroid.com/updates/
5. Click ok button.
6. Click next button. During installation you must see below warning pop up,
7. Click on “OK” button of warning popup window..
Testdroid recorder is capture user action , generate reusable android test case into robotium framework. For more detail about Testdroid visit link “click here”
Prerequisites:
- Eclipse should be installed in your machine.
- Android SDK should be installed.
- ADT Plug-in installed in to Eclipse.
1. Start Eclipse and go to Help -> Install New Software
2. Click Add button; enter to field asking you a site to work with.
3. Fill in “Testdroid plug-in” for the Name
4. For the Location provide URL to Testdroid repository: http://www.testdroid.com/updates/
5. Click ok button.
6. Click next button. During installation you must see below warning pop up,
7. Click on “OK” button of warning popup window..
8. After successful installation restart your eclipse.
Creating project in eclipse:
1. Create new android test project.
2. Click next button.
3. Enter project name and click on next button.
4. Chose Android API and click finish button.
Run Emulator:
Run your emulator having API 11 or as per your selection.
Recording test Script:
1. Goto File menu and select New > Other and select option “New Robotium Test”.
2. Click next button.
3. Enter user name and password of Testdroid application and Click Authorize button.
4. Click next button. Browse your apk file and click next button again.
5. Select recording method name and click on recording button. Your apk file will install in opened emulator , launch the application on emulator and start the recording.
6. After recording click on stop recording button and click on finished button. Your recorded scenario automated converted in java junit test and save in eclipse like as below java code.
import
android.test.ActivityInstrumentationTestCase2;
import
android.app.Activity;
import
junit.framework.AssertionFailedError;
import
com.bitbar.recorder.extensions.ExtSolo;
public class
NewRobotiumTest extends ActivityInstrumentationTestCase2 {
private static final String
LAUNCHER_ACTIVITY_CLASSNAME =
"com.gorillalogic.monkeytalk.demo1.RootActivity";
private static Class
launchActivityClass;
static {
try {
launchActivityClass =
Class.forName(LAUNCHER_ACTIVITY_CLASSNAME);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
private ExtSolo solo; // ExtSolo is an
extension of Robotium Solo that helps
//
collecting better test execution data during test
//
runs
@SuppressWarnings("unchecked")
public NewRobotiumTest() {
super((Class)
launchActivityClass);
}
@Override
public void setUp() throws Exception {
super.setUp();
solo = new
ExtSolo(getInstrumentation(), getActivity(), this.getClass()
.getCanonicalName(),
getName());
}
@Override
public void tearDown() throws Exception {
solo.finishOpenedActivities();
solo.tearDown();
super.tearDown();
}
public void testRecorded() throws Exception {
try {
} catch (AssertionFailedError e) {
solo.fail("NewRobotiumTest.testRecorded_scr_fail",
e);
throw e;
} catch (Exception e) {
solo.fail("NewRobotiumTest.testRecorded_scr_fail",
e);
throw e;
}
}
}
Execution : run java file by choosing “Eclipse Junit launcher” option form eclipse.
Robotium Android Automation with SSAF Online Training, ONLINE TRAINING – IT SUPPORT – CORPORATE TRAINING http://www.21cssindia.com/courses/robotium-android-automation-with-ssaf-online-training-234.html The 21st Century Software Solutions of India offers one of the Largest conglomerations of Software Training, IT Support, Corporate Training institute in India - +919000444287 - +917386622889 - Visakhapatnam,Hyderabad Robotium Android Automation with SSAF Online Training, Robotium Android Automation with SSAF Training, Robotium Android Automation with SSAF, Robotium Android Automation with SSAF Online Training| Robotium Android Automation with SSAF Training| Robotium Android Automation with SSAF| "Courses at 21st Century Software Solutions
ReplyDeleteTalend Online Training -Hyperion Online Training - IBM Unica Online Training - Siteminder Online Training - SharePoint Online Training - Informatica Online Training - SalesForce Online Training - Many more… | Call Us +917386622889 - +919000444287 - contact@21cssindia.com
Visit: http://www.21cssindia.com/courses.html"
Thanks for the great article. i really appreciate it. I have been making research on the internet for a very long time and now come up with something useful.
ReplyDeleteation Virtualisation