I accidentally found that only the test package of APK could be used for automated testing. I was curious, so I recorded it and shared it with you.
1. Environment Configuration:
Android-SDK
Robotium-solo-3.0.jar has been downloaded to local
Re-sign.jar
Test package coup0.apk
2. Create a coupon0 project in eclipse, package name and activity name and Test
The package coupon.apk is the same.
3. Create an android test project coupon800test and a class
Coupontest. Java
The Code is as follows:
Package com. tuan111.coupon111;
Import com. tuan800111 .*;
Import com. jayway. Android. robotium. Solo. Solo;
Import Android. Test. activityinstrumentationtestcase2;
Import Android. Test. suitebuilder. annotation. smoke;
Public class coupon11test extends
Activityinstrumentationtestcase2 {
Private Solo;
Public coupontest () throws classnotfoundexception {
Super ("com. tua0.coupon", splashactivity. Class );
}
Public void setup () throws exception {
Solo = new solo (getinstrumentation (),
Getactivity ());
}
@ Smoke
Public void testopentext () throws exception {
Solo. clickonscreen (120,310); // open item text
Solo. clickinlist (1); // open item
Linkify
Boolean expected = true;
Solo. Sleep (3000 );
Boolean actual = solo. searchtext ("(? I ).*? Some
Text ");
Assertequals ("some text is not found ",
Expected,
Actual); // assert that some text is found
Solo. gobacktoactivity ("apidemos ");
Solo. Sleep (3000 );
}
@ Override
Public void teardown () throws exception {
Try {
Solo. Finalize (); // robotium will finish all
Activities that have been open
} Catch (throwable e ){
E. printstacktrace ();
}
Getactivity (). Finish ();
Super. teardown ();
}
}
4. The code in androidmanifest. XML is as follows:
<? XML version = "1.0" encoding = "UTF-8"?>
<Manifest
Xmlns: Android = "http://schemas.android.com/apk/res/androi
D"
Package = "com. tuan800.coupon"
Android: versioncode = "1"
Android: versionname = "1.0" type = "codeph" text = "/codeph">
<Uses-SDK Android: minsdkversion = "8"/>
<Instrumentation
Android: targetpackage = "com. tuan800.coupon"
Android: Name = "android. Test. instrumentationtestrunner"/>
<Application Android: icon = "@ drawable/icon"
Android: Label = "@ string/app_name">
<Uses-library Android: Name = "android. Test. Runner"/>
</Application>
</Manifest>
5. The following problems occur after running:
[2012-03-04 21:57:44-coupo0test] launching
Instrumentation Android. Test. instrumentationtestrunner
On device emulator 555
[2012-03-04 21:57:46-coupon0test] collecting Test
Information
[2012-03-04 21:57:51-coupon8test] Test Run failed:
Unable to find instrumentation info for: componentinfo
{Com. tua00.coupon/Android. Test. instrumentationtestrunn
Er}