Build an android unit test environment

Source: Internet
Author: User

We often write many methods when writing an activity. In order to enable our method to implement our function, we need to perform unit test first. So every time we develop an activity, first, we need to build a unit test environment.

Methods:

1. When creating a class, it inherits from androidtestcase

2. Add the following two pieces of code to the manifest. xml file:

<uses-library android:name="android.test.runner"
/>// Introduce the Test Library and place it in the application

<! -- Indicates the name of the target package and instrumentation to be tested. --

< instrumentation
android:targetPackage
= "Packages to be tested"Android: Name = "android.test.InstrumentationTestRunner"
/>   3. Write the method of the target method to be tested.   Based on the above three points, you can build a unit test environment.

 

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