Slide 1

Slide 1 text

Pragmatic Mobile Testing Strategies Erik Jhordan Rey Android Tech Lead at Segundamano [email protected] @ErikJhordan_Rey github.com/erikcaffrey

Slide 2

Slide 2 text

/ SCHIBSTED MEDIA GROUP Erik Jhordan Rey Passionate about write quality code, focused to improving the profession of software development. Android Tech Lead at Segundamano

Slide 3

Slide 3 text

/ SCHIBSTED MEDIA GROUP Presence in 30 Countries Y seguimos creciendo MÉXICO Colombia Chile Brasil República Dominicana LATINOAMÉRICA Noruega Suecia Finlandia Bélgica Francia ESCANDINAVIA / EUROPA Portugal Alemania Polonia España Italia Irlanda Suiza Austria Hungría Rumania Bielorrusia Reino Unido Marruecos ÁFRÍCA Túnez Malasia Indonesia Singapur Vietnam Tailandia Bangladés ASIA / OCEANÍA

Slide 4

Slide 4 text

Why writing high-quality software is complicated?

Slide 5

Slide 5 text

/ SCHIBSTED MEDIA GROUP Failed Software Development There are a lot of reasons why a software development project can fail but one of the most common reason is:

Slide 6

Slide 6 text

Software Engineers forgetting to write automated tests!!

Slide 7

Slide 7 text

Testing?

Slide 8

Slide 8 text

/ SCHIBSTED MEDIA GROUP Testing Testing is the process of executing a program with the intent of finding errors… Glenford J Myers

Slide 9

Slide 9 text

Excuses used to avoid write tests

Slide 10

Slide 10 text

Scared to show that code works as expected.

Slide 11

Slide 11 text

Requires time...

Slide 12

Slide 12 text

Short deadlines

Slide 13

Slide 13 text

People don't understand the value

Slide 14

Slide 14 text

Why motivates you to write test?

Slide 15

Slide 15 text

It’s professional

Slide 16

Slide 16 text

It is our responsibility

Slide 17

Slide 17 text

Give value to users & teammates

Slide 18

Slide 18 text

The only way to make refactor

Slide 19

Slide 19 text

It’s a tool for design

Slide 20

Slide 20 text

It’s Money

Slide 21

Slide 21 text

Validate our software

Slide 22

Slide 22 text

Document Behavior our System

Slide 23

Slide 23 text

“Bad code affect your customers, Martin Fowler”

Slide 24

Slide 24 text

As Software engineers, we found problems to write automated tests.

Slide 25

Slide 25 text

Our code is not ready to be tested.

Slide 26

Slide 26 text

Developers start writing tests without knowing what to test and how to test it.

Slide 27

Slide 27 text

Unreliable Tests ( falses / positives)

Slide 28

Slide 28 text

Code coverage != Test quality

Slide 29

Slide 29 text

“Mock” everywhere

Slide 30

Slide 30 text

“Verify” everywhere

Slide 31

Slide 31 text

Strong follower of Mike Cohn’s Test Pyramid

Slide 32

Slide 32 text

/ SCHIBSTED MEDIA GROUP Reliability Testing We are wasting time & life if we don't have reliable tests.

Slide 33

Slide 33 text

Testable Code + Testing Strategies

Slide 34

Slide 34 text

Testable Code

Slide 35

Slide 35 text

Dependency Inversion Principle

Slide 36

Slide 36 text

“Your code should always depend on abstractions and not concretions”

Slide 37

Slide 37 text

/ SCHIBSTED MEDIA GROUP Dependency Inversion Principle Hide implementation details creating layers with different responsibilities.

Slide 38

Slide 38 text

SMMX Clean Architecture

Slide 39

Slide 39 text

/ SCHIBSTED MEDIA GROUP

Slide 40

Slide 40 text

Testing Strategies

Slide 41

Slide 41 text

What do we need to test?

Slide 42

Slide 42 text

Business logic & Requirements

Slide 43

Slide 43 text

/ SCHIBSTED MEDIA GROUP Business Logic We need to test the application implements the business rules.

Slide 44

Slide 44 text

Integration with API

Slide 45

Slide 45 text

/ SCHIBSTED MEDIA GROUP Server Side API integration The software should be prepared to alter software state according to Http Responses / Requests and JSON parsing expected.

Slide 46

Slide 46 text

Integration with Persistence Library

Slide 47

Slide 47 text

/ SCHIBSTED MEDIA GROUP Persistence integration The queries we write to handle data from/to the local DB is working with our system correctly.

Slide 48

Slide 48 text

UI Components

Slide 49

Slide 49 text

/ SCHIBSTED MEDIA GROUP UI Componets it's common to write custom views to be reused in a lot of places of the application so we need to ensure are working as expected.

Slide 50

Slide 50 text

App User Interface

Slide 51

Slide 51 text

/ SCHIBSTED MEDIA GROUP User Interface The user is watching the expected UI according to app interactions and actions.

Slide 52

Slide 52 text

How to test it?

Slide 53

Slide 53 text

/ SCHIBSTED MEDIA GROUP

Slide 54

Slide 54 text

/ SCHIBSTED MEDIA GROUP Testing Stack hiding Implementation details, you can use test doubles ● JUnit ● Mockito ● Hamcrest ● MockWebServer or WireMock ● Persistence Room Testing ● Expresso ● Barista ● Shot

Slide 55

Slide 55 text

Show me code!

Slide 56

Slide 56 text

Business logic & Requirements

Slide 57

Slide 57 text

/ SCHIBSTED MEDIA GROUP Business Logic hiding Implementation details, you can use test doubles

Slide 58

Slide 58 text

/ SCHIBSTED MEDIA GROUP Verify create verify tests is not enough

Slide 59

Slide 59 text

/ SCHIBSTED MEDIA GROUP Ensure Software States Check the final software state.

Slide 60

Slide 60 text

Integration with API

Slide 61

Slide 61 text

/ SCHIBSTED MEDIA GROUP Server Side API integration hiding Implementation details, you can use test doubles

Slide 62

Slide 62 text

/ SCHIBSTED MEDIA GROUP Request contains headers hiding Implementation details, you can use test doubles

Slide 63

Slide 63 text

/ SCHIBSTED MEDIA GROUP Request in correct endpoint hiding Implementation details, you can use test doubles

Slide 64

Slide 64 text

/ SCHIBSTED MEDIA GROUP Mock JSON response AccountResponse.json hiding Implementation details, you can use test doubles

Slide 65

Slide 65 text

/ SCHIBSTED MEDIA GROUP Parsing JSON correctly hiding Implementation details, you can use test doubles

Slide 66

Slide 66 text

/ SCHIBSTED MEDIA GROUP Server Side Api Integration Kotlin Sample to practice Integration Test https://github.com/erikcaffrey/kotlin-integration-test

Slide 67

Slide 67 text

Integration with Persistence Library

Slide 68

Slide 68 text

/ SCHIBSTED MEDIA GROUP Persistence integration hiding Implementation details, you can use test doubles

Slide 69

Slide 69 text

/ SCHIBSTED MEDIA GROUP Handling Queries hiding Implementation details, you can use test doubles

Slide 70

Slide 70 text

UI Components

Slide 71

Slide 71 text

/ SCHIBSTED MEDIA GROUP UI components hiding Implementation details, you can use test doubles

Slide 72

Slide 72 text

/ SCHIBSTED MEDIA GROUP UI Behaviors & States hiding Implementation details, you can use test doubles

Slide 73

Slide 73 text

App User Interface

Slide 74

Slide 74 text

/ SCHIBSTED MEDIA GROUP App UI hiding Implementation details, you can use test doubles

Slide 75

Slide 75 text

/ SCHIBSTED MEDIA GROUP Screenshot Testing hiding Implementation details, you can use test doubles Test framework that checks for visual differences across changes. com.package.segundamano.ads.AdsHolderScreenshots_expiredAd.png

Slide 76

Slide 76 text

Do you think automated software testing matters?

Slide 77

Slide 77 text

Thank You! QA Minds

Slide 78

Slide 78 text

01 02 http://www.wiley.com/WileyCDA/WileyTitle/productCd-1118031962.html The art of Software Testing https://www.amazon.es/Test-Driven-Development-Addison-Wesley-Signature/dp/0321146530 TDD - Kent Beck 03 Further Reading https://goo.gl/sduh0M Clean Code 04 Testad malditos - Jorge Barroso https://www.youtube.com/watch?v=vlorWIlPgY0

Slide 79

Slide 79 text

https://goo.gl/ZWmJPR

Slide 80

Slide 80 text

Questions? Find me Erik Jhordan Rey Android Tech Lead github.com/erikcaffrey [email protected] erikcaffrey.github.io @ErikJhordan_Rey +Erik Jhordan Rey