droidconIN 2015

The fifth edition of droidconIN

Rhishikesh Joshi

@rhishikeshj

Taking unit-testing to the next level

Submitted Oct 16, 2015

Provide in-depth introduction to writing more robust unit tests for your Android applications using property based testing

Outline

Property-based tests make statements about the output of your code based on the input, and these statements are verified for many different possible inputs.
A property-based testing framework runs the same test over and over with generated input.
This contrasts with example-based testing, which is most of the tests we write these days. Each unit test sets up one input scenario, runs the code under test, and then checks the output (and any other effects the code is supposed to have).

Instead, one property-based test runs hundreds of times with different inputs. The testing framework will try to get the test to fail by passing empty lists, negative values, all the possible edges cases. It’ll pass in long lists and high numbers and strings with special characters.

Outline of the Talk

  • Current state of the art for Android unit testing

** JUnit

** Android test cases

** Mocks and stubs

*** Powermock

*** Mockito

  • Shortcomings of traditional unit testing approach

  • Property based testing

** What ?

** How ?

** Why ?

  • Elements of property based testing

  • How to write a property based test for a pure function

** Example code walkthrough.

  • Property based testing for stateful functions.

** Example code walkthrough.

  • Alternative projects you can use

** fj.test

** JCheck

** ScalaCheck

** QuickCheck

  • Writing your own generators for random data.

  • Q & A

Requirements

Prior knowledge of writing unit-tests for Java/Android applications

Speaker bio

Programming language enthusiast, polyglot, learner, mobile developer @Helpshift, coffee addict

Comments

{{ gettext('Login to leave a comment') }}

{{ gettext('Post a comment…') }}
{{ gettext('New comment') }}
{{ formTitle }}

{{ errorMsg }}

{{ gettext('No comments posted yet') }}

Hosted by

droidconIN is an annual conference on Android, part of the worldwide series of events. more