addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1linklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Build and Test an Android app with Colin Miller: Robolectric & Mockito

Howdy folks!

We're very happy to be bringing you another great live code on Thursday, May 8 at 7pm with Colin Miller (Sr. software engineer @ LinkedIn)!

Testing on Android isn't always easy or straightforward, but it is a key part of creating applications - using the right tools when Testing on Android will help you to increase the robustness of your code, and decrease application development time.

This live code will feature writing Unit Tests for Android using Robolectric and Mockito on a small sample project.

Unit testing on Android is in a sorry state. Tests require an emulator or real device to run. This is slow because your tests need to spin up an emulator, copy files, run the tests, and transfer the results back. They can’t be run headless and there often isn’t an easy way of testing your networking code. Slow tests means you’re less likely to follow good testing practices or make testing a top priority in your projects.

The solution is Robolectric, a testing framework for Android that allows you to run your tests in a plain JVM without the need for a device or emulator.


Colin Miller is currently working on the flagship Android application at LinkedIn. There, he has implemented and promoted the use of pure unit testing on Android. A big proponent of TDD, Colin has made minor contributions to the Robolectric project, and enforces a practice of ensuring every commit at LinkedIn is accompanied by unit tests. He runs a general programming and android related blog at

Big thanks to Splunk for providing the venue, food, and drinks!

As always, we encourage you to bring your laptops and contribute your questions. 

See you there!

TJ & the BeMyApp team

Join or login to comment.

  • Nico K.

    I like to show you an example project with robolectric + jacoco and many other nice tools:

    May 9, 2014

  • Iker J.

    I found this nasty hack to make Roboelectric to work in Android Studio and solve the dependency order problem. Setup the run VM options manually specifying the classpath with JUnit in front of the android jar. Anyway, I think following Colin's advise and using IntelliJ will be better for this.

    May 8, 2014

  • Daniel T.

    Are there any bike racks available at the venue that we can use?

    May 8, 2014

  • Sheena S.

    Hi Everyone,
    Really happy to be here. I would like to work with fellow startups/android developers who could take up our client projects.

    May 7, 2014

  • Frieder B.

    Sounds interesting, looking forward to this. I would also like to see more Gradle based tests, possibly including code coverage using the latest JaCoCo support added with the Gradle Android plugin 0.10.+. Please fix the typo in the meetup title - It's Robolectric, not Roboelectric.

    May 6, 2014

    • Colin M.

      The project has been updated to include a gradle build file along with the maven one. It's using android plugin 0.10.0. The tests will run on the command-line via gradle. I haven't gotten it to work in the IDE yet, but that might just be us having to annoy Google tools-dev until they fix their stuff.

      May 6, 2014

    • Wei W.

      This gradle build script won't work if I have android instrumentation tests in this project. It will break instrumentation tests.

      May 7, 2014

  • Katherine

    Hi TJ & Colin,

    Can this session be recorded, just a screen recording of Colin's machine along with the audio of his explanations of the whys?

    I've only done this the low-tech way with a USB headset mic:

    for Macs:
    for PCs:
    for Linux: (if anyone knows how, then I want to know too -- last time I used RecordMyDesktop it dropped the audio a few minutes into an hour session)

    Not sure I can make this great event, but hearing the discussion along with the work is really invaluable -- and having the ability to rewind & repeat too.

    Understandable if this isn't possible to arrange at the last minute, but going forward this would be a great addition to your regular Live Code event.



    2 · May 6, 2014

  • Leonardo S.

    Test test test!

    May 5, 2014

  • Colin M.


    As the meetup description states, this is going to be about writing unit tests using Robolectric for a small app. I wrote a very quick TODO app over the weekend to have something to test. Here's the github for it if you want to check it out beforehand:

    Also, if you want to mess around with adding features or anything, feel free to do so and give me pull requests. This is especially useful if you want to see how something might get tested. I'll probably be adding a few things to this simple app through this week to get us something interesting to test.

    May 5, 2014

    • Colin M.

      We actually use gradle at LinkedIn as well. I'm using maven here because Google's gradle support is still a beta project that doesn't support external tests very well (IE: They can't be run natively in IntelliJ). So to add robolectric tests for Gradle you'll need to run them on the command-line.

      May 5, 2014

    • Colin M.

      Oh, that being said. I'll make up a gradle file as well as an option and show how (and that it does in fact work) with gradle.

      2 · May 5, 2014

  • Vladimir B.

    Hi Colin

    It would be really useful if you can add support for gradle, since not many people actually using android with maven, thanks!

    1 · May 5, 2014

  • Leonardo S.

    Test test test!

    April 24, 2014

  • Marie Antoinette L.

    I would love to attend this but have class that night. Will definitely check out Robolectric and Colin's blog, Thanks, TJ!

    April 23, 2014

Our Sponsors

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy