Android Test: zero-based 3--instrumented unit Test 1

Source: Internet
Author: User

Instrumented unit testing refers to testing that runs on a physical machine or simulator, so you can use the Android framework's API and the supporting API. This will be the case where you need to use device information, such as app context, you can use the instrumented unit test. Using the instrumented unit test can also reduce the code of the Mock (and, of course, the code to write the mock).

The generic test code is placed below the app/src/androidtest/java/. You need to introduce a dependent library in the Build.gradle configuration before starting the test:

dependencies {    androidtestcompile ' com.android.support:support-annotations:24.0.0 '    androidtestcompile ' com.android.support.test:runner:0.5 '    androidtestcompile ' com.android.support.test:rules:0.5 '    //Optional --hamcrest Library    androidtestcompile ' org.hamcrest:hamcrest-library:1.3 '    //Optional-UI testing with Espresso    androidtestcompile ' com.android.support.test.espresso:espresso-core:2.2.2 '    //Optional--UI Testing with UI Automator    androidtestcompile ' com.android.support.test.uiautomator:uiautomator-v18:2.1.2 '}

If the configuration contains both the Support-annotation library and the Espress-core library, the build may fail. You need to add in the configuration:

Androidtestcompile (' com.android.support.test.espresso:espresso-core:2.2.2 ', {    exclude group: ' Com.android.support ', module: ' Support-annotations '})

Android Test: zero-based 3--instrumented unit Test 1

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.