|
[2012-04-26 17:59:28 - calculatortestwithapk] Test run failed: Unable to find instrumentation info for: ComponentInfo{com.calculator/android.test.InstrumentationTestRunner}
测试的是只有APK的应用,没有源码,基于源码的Robotium自动化测试已经调试成功,现在在调试没有源码,只有apk的自动化用例。
测试的是calculator
包名:com.calculator
activity:com.calculator.Main
package com.calculator;
import com.jayway.android.robotium.solo.Solo;
import android.test.ActivityInstrumentationTestCase2;
@SuppressWarnings("unchecked")
public class calculatortest extends ActivityInstrumentationTestCase2{
private static final String TARGET_PACKAGE_ID="com.calculator";
private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME="com.calculator.Main";
private static Class launcherActivityClass;
static{
try
{
launcherActivityClass=Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
} catch (ClassNotFoundException e){
throw new RuntimeException(e);
}
}
public calculatortest()throws ClassNotFoundException{
super(TARGET_PACKAGE_ID,launcherActivityClass);
}
private Solo solo;
@Override
public void setUp() throws Exception{
solo = new Solo(getInstrumentation(),getActivity());
}
public void testDisplayBlackBox() throws Exception{
//Enter any integer/decimal value for first editfield, we are writing 10
solo.enterText(0, "10");
//Enter any interger/decimal value for first editfield, we are writing 20
solo.enterText(1, "20");
//Click on Multiply button
solo.clickOnButton("Multiply");
//Verify that resultant of 10 x 20
assertTrue(solo.searchText("200"));
}
@Override
public void tearDown() throws Exception {
try {
solo.finalize(); //Robotium will finish all the activities that have been open
} catch (Throwable e) {
e.printStackTrace();
}
getActivity().finish();
super.tearDown();
}
} |
|