Android test: Start from scratch introduction

Source: Internet
Author: User

Reference Document: Https://developer.android.com/training/testing/start/index.html

Test classification

To test with Android studio, you first need to understand the classification of Android tests, and after you create a new project, the project will default to two test catalogs:

1. Local unit Test (tests)

The test code is locatedmodule-name/src/test/java/,这些测试直接运行在本地JVM上,不需要使用Android框架的API。

2, Equipment testing (instrumented tests)

The test code is located in located atmodule-name/src/androidTest/java/,这些测试代码必须运行在Android设备或者Android虚拟机上。

The instrumented test code is packaged into an apk and then runs on the phone. Because running on the device, you can use some of the methods inside the app, modify some properties, and automate the simulation of user interaction.

The above two classifications are based on whether the test runs on the local JVM or is run on the Android platform. A complete set of tests are categorized as follows:

Type Sub-type Describe
Unit Test Native Unit Testing (local units Tests) A unit test that runs on the local JVM. You can use this test to reduce test execution time when the code being tested does not depend on the Android framework API, or when simulating androidapi.
Device Unit Test (instrumented unit tests) Unit tests that run on Android devices or emulators. These tests run with the need for device information, such as the context of the app.
Integration Testing App Component Testing This type of test is to verify that the app responds as expected when the user makes certain actions on the activity or enters certain values.
Cross-app component testing This type of test is intended to verify the correct behavior when interacting between the user app and the system app.

Test API

Here are some of the generic Test APIs that are introduced on Android

1. JUnit

2. Android Testing Support Library (Androidjunitrunner,espresso,ui Automator)

3, assertion classes (Hamcrest library)

4, Monkey and Mokeyrunner

You will then describe how to use it separately.

Android test: Start from scratch introduction

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.