droidconIN 2015

The fifth edition of droidconIN

Taking unit-testing to the next level

Submitted by Rhishikesh Joshi (@rhishikeshj) on Friday, 16 October 2015

videocam_off

Technical level

Intermediate

Section

Core Development - Full talk (45 minutes)

Status

Submitted

Vote on this proposal

Login to vote

Total votes:  +22

Objective

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

Description

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

Links

Comments

Login with Twitter or Google to leave a comment