Droid con 2013 workshop unit testing in android [robolectirc]
Click here to load reader
-
Upload
leena-s-n -
Category
Technology
-
view
275 -
download
1
description
Transcript of Droid con 2013 workshop unit testing in android [robolectirc]
Unit Testing Android Applications
Leena SNHead of Engineering@leenasn
Krishnaprasad RSoftware Architect@krikrn
Multunus Software Pvt. Ltd.Agile Software Development@multunus
Demo of AndroidUnitTestCase
AndroidInstrumentationTestCase
● Extension to JUnit● Provides wrappers for instantiating Activities ● Provide methods for interacting with
Activities
The Problem
● Slow tests● Resulting in slow iterations
The Solution
● Mocking ● But its not easy :(
● Google has stripped all the classes with android.jar with RuntimeException(“Stub”)
● Most classes and methods are final● Non public constructors● Lack of interfaces● Many static methods
Mocking is Hard because..
● Faster tests - runs in JVM● Emulates Android SDK and Resources
Why Robolectric?
Lets see it in action!
● Emulates Android SDK, modified to run it on JVM Using○ Shadow Objects○ View and Resource Loading
How it works
● Extending Robolectric is easy too● Awesome Community Support
What is Special
● Never runs on actual device as it emulates the environment
● It can test small units, so can not replace automated integration tests
● The above are for purpose :)
What Robolectric is NOT
Summary
http://bit.ly/android-robolectrichttp://bit.ly/how-robolectrichttp://bit.ly/multunus-robo-samplehttp://bit.ly/robolectric-blog
References