Clojure Gazette 133: TDD in Clojure on Android

TDD in Clojure on Android


Issue 133 - July 20, 2015


This week I was lucky enough to interview Alexander Yakushev, who is working on the clojure-android project. I've interviewed him twice before. You can find them in Clojure Gazette issues 1.9 and 1.78 . Also check out his recent talk from EuroClojure .

Please enjoy the issue!

Rock on!

PS Want to be more attractive? Subscribe !
PPS Want to advertise to smart, talented, attractive Clojure devs ?


Sponsor: Homegrown Labs

Unit tests exercise the individual parts of your system. And acceptance tests make sure the business requirements are met. If you're worried about how much failure in production will cost in your complex, distributed, and unpredictable system, Homegrown Labs can help build your confidence. Homegrown Labs specializes in Simulation Testing, which tests your system as a whole by simulating a realistic workload. Please support the Gazette by visiting Homegrown Labs and signing up to learn more about Simulation Testing at the bottom of the page.

LispCast: Can you describe your project?

Alexander Yakushev: This year I've taken on something very specific to Clojure-Android. I'm developing a Clojure-Android testing framework. In order to grasp what is challenging about this project it must be said that testing Android applications is a cumbersome task. By default it requires a real device or an emulator, tests take very long to execute, testing with different Android versions becomes even harder, and so on. Another way to do it is to employ Robolectric library which allows Android tests on JVM almost as if the were run on the device.

The TDD framework I develop allows to use Robolectric from Clojure-Android projects. Apart from this, other important things have to be taken care of: helper functions/macros to use Robolectric more easily from Clojure, integration with lein-droid (Clojure-Android build tool), support for CI services like Travis . To serve as examples and pioneer consumers of this framework, Clojure-Android projects themselves (e.g., Neko and lein-droid) need tests to be written for them.

LC: What are the main challenges with your project?

AY: The biggest challenge so far was to make Robolectric work with Clojure projects. Robolectric uses some voodoo classloader magic to substitute Android stub classes with actual implementations, and this classloader doesn't play along well with Clojure classloaders. I have a solution for that already, but it is quite hacky, so I plan to ultimately get to the bottom of it.

Another incidental trouble is that Robolectric is very closely tied to JUnit while my project aims to be testing lib-independent. Right now I support clojure.test, Expectations and Speclj. Midje might be added as well although unlikely - it has some fairly complex bootstrapping sequence which fails to load under Robilectric's classloader.

One more challenge I can name is making tests run faster. Even with Robolectric it takes a solid while to run through the test suite for multiple Android versions. I plan to tackle this issue by revisiting my last year's project - Skummet - and adapting it for compiling and running tests.

LC: You've done GSoC three times now, is that right? Would you recommend it to other students? Do you have any advice for others working on their own projects?

AY: That's correct, it's my fourth GSoC already. I totally recommend it to other students, and the main advice I have is: don't give up on your project after the summer ends. GSoC, for me at least, is primarily a chance to become a part of the community you love. Don't settle for mundane things like money or work experience, seize the moment and create something useful for other people while you have a little spotlight that GSoC provides you with.

LC: What's the state of the project? Can people help out?

AY: My current work is spread out among multiple projects, but all of them are united under banner. There are definitely ways to help, for example write more complicated tests for Neko to discover new patterns and tools that should be included into the testing framework, and to check if the current implementation works with complex tests.

LC: If people want to follow your progress, where can they do that?

AY: The progress can be tracked by the Github link above, and on where I, among other things, publish reports and speculations about the GSoC projects.

LC: If people want to get in touch with you online, where is the best place for that?

AY: Usually the easiest place to find me is on #clojure-android channel @ Freenode. We have a Google mailing list called, surprise surprise, clojure-android .

LC: If Clojure were a spaceship, which planetary system would it hail from?

AY: Clojure battlecruiser has a mixed crew. Some come from Alterir star system, full of dark mutability and chaos. Some are from distant Lambda Centauri st ar which is so big that the time stops in its vicinity and nothing ever changes. Currently Clojure flies under Javvah banner, but rumors say that Androidmeda and Scriptius systems learned the secret craft of building Clojure spaceships. Tune up for more intergalactic news after the space weather forecast. Back to you, Eric.

LC: Thanks for a great interview.

AY: Thanks for having me! It's always a great pleasure to talk to you, as much as reading Clojure Gazette. Thank you for doing this and for creating a window into the Clojure world for all of us.