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();
}
}
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();
}
}
本文介绍了一个使用Robotium进行的黑盒测试案例,通过测试新闻应用的设置功能验证其可用性。该测试覆盖了应用启动、操作模拟及测试清理等关键步骤。
736

被折叠的 条评论
为什么被折叠?



