Unit and automation testing on Android
Unit and automation testing on Android
Automation tests are important, as they guarantee a property when examining an application. TDD guarantees the execution of written studies before writing the implementation.
To obtain additional information about TDD, refer to the previous control.
Testing pyramid:
- Unit tests cover a large section of the pyramid, making a solid base. Unit tests are elementary in writing.
- Integration: the test ensures the correct integration of modules and embraces the 2nd great piece of the pyramid.
Functional testing: traditionally describes what the system is preparing, and takes the smaller of 3 shares. There are a lot of testing devices and frameworks that are allowed to be used in the study of the addition.
Some of them are given and supported by Google, and some of them are considered a third party.
Types of testing on Android:
Unit Test
Unit tests in the main are aimed at the least work capacity (for example, a method, a class that composes or a small fraction) with isolation from other components. Appliances used for unit tests
- JUnit are probably the usual design for recording renewable studies. Probably a copy of the xUnit Architecture for modules of the unit test.
- Robolectric - the famous apron of the Android test, which allows you to do the tests sooner, launching tests on the JVM (no need for an appliance, no emulator).
Instrumentation Test
Instrumentation Test (UI) - Perhaps it feels like it is modeling the interaction with the user, for example, by pressing the "Get a word in EditText" button. Android Instrumentation perhaps a set of "hooks" in the Android system, which allows you to rule the life cycle of Android components (ie, Edit the current energy cycle in the absence of support for the rest, and not to rule them in the system). For these studies, you need to hurl this unit or emulator.
Tools used for Instrumentation Test:
* Espresso — Android UI Test Framework provided by Google that handles test synchronization very well;
* UIAutomator — Android UI Test Framework provided by Google for testing across multiple apps at the same time;
* Robotium — Third-party Android UI Test Framework (Robotium vs Espresso);
* Selendroid — Selenium for Android.
Package Structure for Testing:
In our plan, two folders contain our tests, which are listed as test and androidTest.
Analysis: Unit tests are located in this folder. These tests are performed on the JVM and do not strongly request a special Android device or emulator. This type of test does not have access to a specific component specific to Android, for example, Context.
Tests for Android: all tests of inventory (espresso) are located in this folder. For the test, you need a physiological instrument or an Android emulator for starting.
Also, you can read Software testing - basic concepts and definitions and Software Testing: Quality From the Beginning.