Open TechnoMag82 opened 7 years ago
See the getting started here:https://github.com/RobotiumTech/robotium/wiki/Getting-Started this may resolve your problem:
public void setUp() throws Exception {
solo = new Solo(getInstrumentation(), getActivity());
}
DeliveryActivity extends Fragment.
public void setUp() throws Exception {
solo = new Solo(getInstrumentation(), getActivity());
}
java.lang.RuntimeException: Could not launch activity
public NewRobotiumTest() {
super(PACKAGE_NAME, Class.forName(LAUNCHER_ACTIVITY_CLASSNAME););
}
the first parameter is package name; second is launched activity
Thanks. Problem solved with code:
public class DeliveryActivityTest extends ActivityInstrumentationTestCase2 {
private static final String LAUNCHER_ACTIVITY_CLASSNAME = "com.delivery.example";
private static Class<?> launchActivityClass;
static {
try {
launchActivityClass = Class.forName(LAUNCHER_ACTIVITY_CLASSNAME);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
private Solo solo;
public DeliveryActivityTest(Class<DeliveryActivity> activityClass) {
super(activityClass);
}
public void setUp() throws Exception {
super.setUp();
solo = new Solo(getInstrumentation(), getActivity());
}
@Override
public void tearDown() throws Exception {
solo.finishOpenedActivities();
super.tearDown();
}
@SuppressWarnings("unchecked")
public DeliveryActivityTest() {
super((Class<DeliveryActivity>) launchActivityClass);
}
public void testButton()
{
solo.clickOnText("Some button");
}
}
After start test, application not started automatically for testing. I must manually launch application by tap on icon.
Error by timeout: junit.framework.AssertionFailedError: Text string: 'Some button' is not found!
My test: DeliveryActivity is not first Activity in backstack when application launched.