//Step 1: Write the following sentence on the <activity> tag in the androidmainfest. xml fileCode
<Uses-library Android: Name = "android. Test. Runner"/>
// In androidmainfest. xml </Application>, enter the following code.ProgramPackage name
<Instrumentation Android: Name = "android. Test. instrumentationtestrunner" Android: targetpackage = "cn. itcast. Action" Android: Label = "tests for my app"/>
//Step 2: Compile the unit test code (select the method to be tested, right-click "Run as" -- "android JUnit test "):
Package CN. itcast. test;
Import JUnit. Framework. Assert;
Import CN. itcast. Service. personservice;
Import Android. Test. androidtestcase;
Public class personservicetest extends androidtestcase {
Private Static final string tag = "personservicetest ";
Public void testsave () throws throwable {
Personservice service = new personservice ();
Int B = service. Save (); // check whether the SAVE () method runs normally.
Assert. assertequals (78, B); // whether the expected value 78 is the same as the obtained value B
Log. I (TAG, B}; // Add a filter to logcat to view the printed information.
}