14
Welcome TDD IN ANDROID Let's see how you can apply TDD in the Android ecosystem

Tdd in android (mvp)

Embed Size (px)

Citation preview

Page 1: Tdd in android (mvp)

We l c ome

TDD IN ANDROIDLet's see how you can apply TDD in the Android ecosystem

Page 2: Tdd in android (mvp)

What is TDD

2

Write a Failing Test

Make the (failing) Test PassRefactor

Page 3: Tdd in android (mvp)

Example

3

Page 4: Tdd in android (mvp)

Example

4

Page 5: Tdd in android (mvp)

Example

5

Page 6: Tdd in android (mvp)

Example

6

Page 7: Tdd in android (mvp)

Example

7

Page 8: Tdd in android (mvp)

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

Page 9: Tdd in android (mvp)

Separation of Concerns

9

• Define the concerns of different components in Codebase • Create different layers as per their responsibility• Test each layer separately

Page 10: Tdd in android (mvp)

Demo screen

10

Invalid Login

Valid Login

Page 11: Tdd in android (mvp)

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

Page 12: Tdd in android (mvp)

Testing mechanisms in Android

12

• Unit Test

๏Junit

๏Mockito

• Integration Test

๏Espresso

๏Junit

Page 13: Tdd in android (mvp)

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)

Page 14: Tdd in android (mvp)

THANK YOU

For questions or suggestions:

Prateek Jain: [email protected]