Slide 1

Slide 1 text

@fernando_cejas Code samples: https://github.com/android10/Inside_Android_Testing https://github.com/android10/AndroidApplicationTestingSample

Slide 2

Slide 2 text

Who am I? •  GDG Organizer •  Android, Agile and technology Geek •  NFC Actions App •  Mobile Developer @fernando_cejas http://www.fernandocejas.com/

Slide 3

Slide 3 text

Agenda •  Why testing? •  Types of tests •  What to test on Android •  Tools for testing – JUnit – Mockito – Robolectric – Test Framework  

Slide 4

Slide 4 text

Why testing? •  Testing increases the level of confidence in your code. •  Testing makes it possible to write new code, and refactor existing code, without worrying that you’ve broken existing functionality.

Slide 5

Slide 5 text

Types of Tests

Slide 6

Slide 6 text

Testing on Android… Tools… •  Junit •  Mockito •  Robolectric •  Test Framework

Slide 7

Slide 7 text

JUnit •  JUnit is an open source framework that has been designed for the purpose of writing and running unit tests in Java.

Slide 8

Slide 8 text

Mockito •  Mocking Frameworks allow us to test the code you want, without its dependencies. •  Mock objects can simulate the behaviour of complex objects. •  Mock objects isolate the unit of code you are testing.

Slide 9

Slide 9 text

Code Sample

Slide 10

Slide 10 text

Robolectric •  Robolectric is a unit test framework that de-fangs the Android SDK jar so you can test-drive the development of your Android app. •  It rewrites Android SDK classes as they're being loaded and making it possible for them to run on a regular JVM.

Slide 11

Slide 11 text

Code Sample

Slide 12

Slide 12 text

Android Test Framework •  Offered by the android framework. •  Needs an emulator to execute the tests •  Lets write unit, integration and functional tests. •  Has its own mocking framework

Slide 13

Slide 13 text

Code Sample

Slide 14

Slide 14 text

More tools… •  Fest •  Spoon •  Robotium •  UI Automator •  Monkey Runner •  Strict Mode

Slide 15

Slide 15 text

Some useful concepts… •  Dependency Injection •  Code coverage •  Continuous Integration

Slide 16

Slide 16 text

Conclusion There is virtually no reason why you should not be testing.

Slide 17

Slide 17 text

Any questions?

Slide 18

Slide 18 text

Thanks! @fernando_cejas https://github.com/android10 www.fernandocejas.com http://corporate.tuenti.com/es/dev/blog