Android automated testing - robotium (six) only APK exists

Previous robotium tests were based on source code. When we can't get the android source code, we can use another way to test. Regarding this method, the robotium wiki has relevant information for reference RobotiumForAPKFiles:Use Robotium when only having apk

http://code.google.com/p/robotium/wiki/RobotiumForAPKFiles

 

Before implementing the entire testing process, let's take a brief look at Android application signatures:

Why do Android apps need to be signed? What is the purpose of the signature?

The role of the signature:

(1) Authentication of sender identity

(2) Ensure the integrity of the input information

(3) Prevent denials in transactions

 

Robotium starts the testing process:

1. Change the APK signature

According to the robotimu wiki introduction: we need to use a tool called re-sign.jar, which can help us re-sign an APK.

Download: http://down.51cto.com/data/443499

1. Double-click re-sign.jar or java -jar re-sign.jar under cmd

2. Drag the application into the re-sign, here is an example of "Youdao Dictionary 3.1.0.apk"

3. Generate new signature and new APK.

Youdao Dictionary 3.1.0_dubug.apk

Package name:com.youdao.dict

Main activity:com.youdao.dict.activity.DictSplashActivity



 

 

2. Install "Youdao Dictionary 3.1.0_dubug.apk" into the android virtual machine

1. Enter android-sdk-windows\platform and execute the command:

adb install Youdao Dictionary 3.1.0_dubug.apk

2. After the installation is successful, the virtual machine will see this application.



 

 

3. Modify the AndroidMainfest.xml file

Create Android test project: http://luwenjie.blog.51cto.com/925779/908886

  1. <?xmlversion="1.0"encoding="utf-8"?>   
  2. <manifestxmlns:android="http://schemas.android.com/apk/res/android"  
  3.     package="com.luwenjie.helloworld.test" 
  4.     android:versionCode="1" 
  5.     android:versionName="1.0">  
  6.  
  7. //Add supports-screens
  8.     <supports-screens android:anyDensity="true"/> 
  9.      
  10.     <uses-sdkandroid:minSdkVersion="10"/>    
  11.      
  12. //Modify targetPackage to the previously produced Package Name
  13.     <instrumentation 
  14.         android:name="android.test.InstrumentationTestRunner" 
  15.         android:targetPackage="com.youdao.dict"/>  
  16.  
  17.     <application 
  18.         android:icon="@drawable/ic_launcher" 
  19.         android:label="@string/app_name">  
  20.         <uses-libraryandroid:name="android.test.runner"/>   
  21.     </application> 
  22.  
  23. </manifest> 

Fourth, modify the test framework:

The testing framework Robotium Wiki already provides:



 

 

//TARGET_PACKAGE_ID and LAUNCHER_ACTIVITY_FULL_CLASSNAME using tool generated

private static final String TARGET_PACKAGE_ID = "com.youdao.dict"

private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "com.youdao.dict.activity.DictSplashActivity"

 

//Test script, we can modify the script and use java features to create multiple script files for calling

public void testCanOpenSettings(){
       solo.enterText(0, "test");

}

 

Five, run the script to test



 

This article is from the " Xiao Maozi " blog, please keep this source http://xiaomaozi.blog.51cto.com/925779/922261

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326395616&siteId=291194637