How to run TestSuite for Android Testing

Source: Internet
Author: User

Public class StartTest extends InstrumentationTestRunner {public TestSuite getAllTests () {TestSuite suite = new InstrumentationTestSuite (this); suite. addTestSuite (TestRunner. class); return suite;} 1. The class must inherit from InstrumentationTestRunner 2. The function name must be getAllTests (), which is a virtual function of the base class. At the beginning, I never noticed that I had taken a detour. I made a special record. 3. I returned testsuite to the class and modified AndroidManifest. xml. <? Xml version = "1.0" encoding = "UTF-8"?> <Manifest xmlns: android = "http://schemas.android.com/apk/res/android" package = "com. mobile. test "android: versionCode =" 1 "android: versionName =" 1.0 "> <uses-sdk android: minSdkVersion =" 5 "/> <instrumentation android: name =" android. test. instrumentationTestRunner "android: targetPackage =" com. mobile "/> <instrumentation android: targetPackage =" com. mobile "android: name =" com. mobile. test. startTest "/> <! -- Newly added instrumentation, targetPackage is the name of the tested package, and name is the package name of testsuite. class name --> <application android: icon = "@ drawable/ic_launcher" android: label = "@ string/app_name"> <uses-library android: name = "android. test. runner "/> </application> </manifest> you can right-click and execute Run deployments in eclipse... check Run all tests in the selected project, or package. Select the test project name Instrumentation runner, and select com. mobile. test. StartTest configured in xml to run it ~~ You can also use the command line to execute am instrument-w com. mobile. test/. StartTest. Note: adb shell pm list instrumentation can list instrumentation in mobile phones.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.