Current location - Quotes Website - Personality signature - How does robotium test the pre-installed apk?
How does robotium test the pre-installed apk?
Robotium testing Android apk installation package

introduce

The apk program to be tested must have the same signature as the test program we wrote. If there is no signature key of apk program, we should remove the signature of apk program, and then sign it with our own key (we can use debug key in this step). There is a ready-made tool available, and the download address is re-sign.jar This tool can remove the original signature of apk program and then sign it with our own debugging key.

detailed

Before writing test cases, we need to know the package name and launcher activity name of apk program, which can be obtained from adb logcat when the program starts. The program log will print out the package name and activity name. The log format is similar to: start activity: intent {act = Android. intent.action.maincat = Android. intent.category.launcher? flg = 0x 10200000 CMP = com . example . Android . notepad/。 List of notes.

The above log shows that the package name is: com.example.android.notepad, and the startup activity name is: com.example.android.notepad.notelist, where the activity name is LAUNCHER_ACTIVITYFULLCLASSNAME in the following code.

The following is an example of test code:

Package com.yourcompany.yourtestname;

Import com.jayway.android.robotium.solo.solo;

Import android.test.activitystructurationtestcase2;

@ suppress warnings(" raw type ")

Public class ReallyBlackboxTest extends activitystructurationtestcase 2 {

private static final String LAUNCHER _ ACTIVITY _ FULL _ class name = " com . newsrob . dashboard list ACTIVITY ";

Private static class < & gtlauncherActivityClass

Static {

Try {

launcherActivityClass = class . for name(LAUNCHER _ ACTIVITY _ FULL _ class name);

} catch(ClassNotFoundException e){

Throw a new runtimeexception (e);

}

}

@SuppressWarnings ("unchecked")

Public ReallyBlackboxTest () throws ClassNotFoundException {

super(launcherActivityClass);

}

Private solo solo;

@ Overlay

The protected void setting () threw an exception {

Solo = new Solo(getInstrumentation()、get activity());

}

public void testCanOpenSettings(){

solo . press menuitem(0);

}

@ Overlay

Public void tearDown () threw an exception {

solo . finishhopeneddactivities();

}

}