Android JUnit Test

Source: Internet
Author: User

1. Configure <instrumentation>: <instrumentation Android: Name = "android. Test. instrumentationtestrunner" in the manifest file"
Android: targetpackage = "com. BroadVision. proguard"/> as a sub-tag of the manifest tag,
Android: targetpackage is the package name of the test class (subclass of androidtestcase) created in the following steps.

2. configure <uses-library>: <uses-library Android: Name = "android. test. runner "/> as the sub-tag of the <Application> tag (that is, put it in it ).

3. Create a New testcase package: COM. BroadVision. proguard can be any package name, which should be consistent with the package name in step 1.

4. Create a subclass of androidtestcase under the new package, such as maintestcase.

6. Add a test method to the newly created maintestcase class. The method name must start with test and be modified with public void, as shown in figure

Public void testsomething () throws throwable {
// Method body

7. Right-click the project and run it as "android JUnit test". The following result is displayed:


Android executes the Android: Test Method of all androidtestcase subclasses under the targetpackage, and displays them in a tree structure.

Valid information such as the Execution success and execution time of the test methods.

Thank you for your correction.

Related Article

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: 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.