I am trying to write a test that performs a workflow in my app. However; I need to split my test into two parts. The scenario goes something like this:
I start my app, then it starts a Gallery to select an image then goes back to my app to continue with the workflow.
The problem I'm having is that I can't automate actions in the Gallery, so this requires some manual action. So my plan is to automate the first part i.e. start my app and start Gallery then manually select an image and then run the second part of my automated test.
The problem is at the end of the first automation part the activity is closed even if I don't do a tearDown step and call activity.finish()
I have included an example of the code I'm using. So if you could point out what I'm doing wrong here that would be awesome. I should mention that I'm using Robotium for my automation.
package com.myapp.android.testWithAPK;
import com.jayway.android.robotium.solo.Solo;
import android.test.ActivityInstrumentationTestCase2;
public class MyTest extends ActivityInstrumentationTestCase2 {
private static final String TARGET_PACKAGE_ID = "com.myapp.android";
private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME =
"com.myapp.android.ui.Main";
private static Class<?> launcherActivityClass;
static {
try {
launcherActivityClass = Class
.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
@SuppressWarnings("unchecked")
public MyTest() throws ClassNotFoundException {
super(launcherActivityClass);
}
private Solo solo;
@Override
protected void setUp() throws Exception {
solo = new Solo(getInstrumentation());
}
public void testCreatePostCard() throws InterruptedException{
solo.clickOnText("Make a postcard");
solo.clickOnText("Choose photo");