Upload
prateek-jain
View
235
Download
0
Embed Size (px)
Citation preview
We l c ome
TDD IN ANDROIDLet's see how you can apply TDD in the Android ecosystem
What is TDD
2
Write a Failing Test
Make the (failing) Test PassRefactor
Example
3
Example
4
Example
5
Example
6
Example
7
Why TDD is challenge in Android?
8
• Doing every work at one place making it difficult to test another• Mocking of android components is difficult
Separation of Concerns
9
• Define the concerns of different components in Codebase • Create different layers as per their responsibility• Test each layer separately
Demo screen
10
Invalid Login
Valid Login
Layers in Demo Screen
11
View Logic is separated from Data Models
Presenter acts as communicator between Business logic and View logic.
View Actions (Login Activity)
Login Presenter Login Model
Click LoginCheck User Existence
Validate UserUpdate UI Accordingly
Testing mechanisms in Android
12
• Unit Test
๏Junit
๏Mockito
• Integration Test
๏Espresso
๏Junit
What we achieve from TDD
13
• Faster Feedback (Testing at each layer)
• Encourage Good Design (Smaller modules/ Reusability)
• Easily Extensible and Maintainable Code (adding new code is easy/ tweaking existing code)
• Confidence while Refactoring (TDD provides its best results when code is constantly improved)