Unit Testing
Android Applications

Multunus Software Pvt. Ltd.

Leena SN

Krishnaprasad R

Agile Software Development

Hea...
Demo of AndroidUnitTestCase
AndroidInstrumentationTestCase

● Extension to JUnit
● Provides wrappers for instantiating Activities
● Provide methods fo...
The Problem

● Slow tests
● Resulting in slow iterations
The Solution

● Mocking
● But its not easy :(
Mocking is Hard because..
● Google has stripped all the classes with
android.jar with RuntimeException(“Stub”)
● Most clas...
Why Robolectric?

● Faster tests - runs in JVM
● Emulates Android SDK and Resources
Lets see it in action!
How it works

● Emulates Android SDK, modified to run it on
JVM Using
○ Shadow Objects
○ View and Resource Loading
What is Special

● Extending Robolectric is easy too
● Awesome Community Support
What Robolectric is NOT
● Never runs on actual device as it emulates
the environment
● It can test small units, so can not...
Summary
References

http://bit.ly/android-robolectric
http://bit.ly/how-robolectric
http://bit.ly/multunus-robo-sample
http://bit....
Upcoming SlideShare
Loading in …5
×

Droid con 2013 workshop unit testing in android [robolectirc]

559 views

Published on

The presentation we did as part of DroidCon 2013 Workshop

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
559
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
5
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Droid con 2013 workshop unit testing in android [robolectirc]

  1. 1. Unit Testing Android Applications Multunus Software Pvt. Ltd. Leena SN Krishnaprasad R Agile Software Development Head of Engineering Software Architect @multunus @leenasn @krikrn
  2. 2. Demo of AndroidUnitTestCase
  3. 3. AndroidInstrumentationTestCase ● Extension to JUnit ● Provides wrappers for instantiating Activities ● Provide methods for interacting with Activities
  4. 4. The Problem ● Slow tests ● Resulting in slow iterations
  5. 5. The Solution ● Mocking ● But its not easy :(
  6. 6. Mocking is Hard because.. ● 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
  7. 7. Why Robolectric? ● Faster tests - runs in JVM ● Emulates Android SDK and Resources
  8. 8. Lets see it in action!
  9. 9. How it works ● Emulates Android SDK, modified to run it on JVM Using ○ Shadow Objects ○ View and Resource Loading
  10. 10. What is Special ● Extending Robolectric is easy too ● Awesome Community Support
  11. 11. What Robolectric is NOT ● 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 :)
  12. 12. Summary
  13. 13. References http://bit.ly/android-robolectric http://bit.ly/how-robolectric http://bit.ly/multunus-robo-sample http://bit.ly/robolectric-blog

×