12
BY QUSHAY BAGAS Tech Evangelist [email protected]

Unit test Android

Embed Size (px)

Citation preview

Page 1: Unit test Android

BY QUSHAY BAGASTech [email protected]

Page 2: Unit test Android

Unit Testing

Integration Testing

System Testing

Acceptable Testing

Testing process where individual units/components of a software/system are tested. The purpose is to validate that each unit of the software performs as designed.

Testing process where individual units are combined and tested as a group. The purpose of this level of testing is to expose faults in the interaction between integrated units.

Testing process where a complete, integrated system/software is tested. The purpose of this test is to evaluate the system’s compliance with the specified requirements.

Testing process where a system is tested for acceptability. The purpose of this test is to evaluate the system’s compliance with the business requirements and assess whether it is acceptable for delivery.

Page 3: Unit test Android

Unit Test• Unit tests mainly target smallest functionality (like method, class , component

or small module) with isolation from other component.• Tools : JUnit, Roboelectric

Instrumentation Test• Instrumentation Test (UI) are tests that mock User Interaction like clicking

button , Typing text in EditText. Android Instrumentation is a set of “hooks” into the Android system that allows you to control the lifecycle of Android components (i.e. drive the activity lifecycle yourself instead of having these driven by the system). These tests require an actual device or emulator to run .

• Tools : Espresso, Robotium,

Types of testing in Android

Page 4: Unit test Android

HOW ???

Page 5: Unit test Android

White Box Testing

Method of testing the application at the level of the source code.

control flow testing data flow testing branch testing path testing statement coverage decision coverage modified condition/decision

coverage

Page 6: Unit test Android

Criteria Black Box Testing White Box Testing

Definition

Black Box Testing is a software testing method in which the internal structure/ design/ implementation of the item being tested is NOT known to the tester

White Box Testing is a software testing method in which the internal structure/ design/ implementation of the item being tested is known to the tester.

Levels Applicable ToMainly applicable to higher levels of testing:Acceptance TestingSystem Testing

Mainly applicable to lower levels of testing:Unit TestingIntegration Testing

Responsibility Generally, independent Software Testers Generally, Software Developers

Programming Knowledge Not Required Required

Implementation Knowledge Not Required Required

Basis for Test Cases Requirement Specifications Detail Design

Page 7: Unit test Android

WHO ???Performed by software developers themselves

or their peers

Page 8: Unit test Android

WHY ???

Page 9: Unit test Android

Unit testing increases confidence in changing/ maintaining code.

Codes are more reusable

Development is faster

The cost of fixing a defect detected during unit testing is less

Debugging is easy

Codes are more reliable

Page 10: Unit test Android
Page 11: Unit test Android

TipsFind a tool/ framework for your language

Do not create test cases for everything. Focus on the tests that impact the behavior of the system

Isolate the development environment from the test environment

Use test data that is close to that of production

Before fixing a defect, write a test that exposes the defect

Write test cases that are independent of each other

Aim at covering all paths through the unit.

Use a version control system to keep track of your test scripts

Perform unit tests continuously and frequently

Page 12: Unit test Android