robotium 测试APK包

package com.yourcompany.yourtestname;
package com.yourcompany.yourtestname;
import com.jayway.android.robotium.solo.Solo;
import android.test.ActivityInstrumentationTestCase2;

@SuppressWarnings("unchecked")
public class ReallyBlackboxTest extends ActivityInstrumentationTestCase2 {

private static final String TARGET_PACKAGE_ID = "com.newsrob";//被测试的package name
private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "com.newsrob.DashboardListActivity";//Main Activity

private static Class<?> launcherActivityClass;
static{
try {
launcherActivityClass = Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}


@SuppressWarnings("unchecked")
public ReallyBlackboxTest() throws ClassNotFoundException {
super(TARGET_PACKAGE_ID, launcherActivityClass);
}

private Solo solo;

@Override
protected void setUp() throws Exception {
solo = new Solo(getInstrumentation(), getActivity());
}

public void testCanOpenSettings(){
solo.pressMenuItem(0);
}


@Override
public void tearDown() throws Exception {

try {
solo.finalize();
} catch (Throwable e) {

;e.printStackTrace();
}
getActivity().finish();
super.tearDown();


}

}

你可能感兴趣的:(robot)