ANN: Mock Objects on Android with Borachio

by paulbutcher » Mon, 14 Mar 2011 01:25:25 GMT

Sponsored Links
 One of my biggest frustrations with writing code for Android has been
the fact that none of the current Java mocking frameworks work on
Android Dalvik VM. I recently released Borachio a native Scala
mocking framework which does work on Android.

Because Borachio is written in Scala, youl need to write your tests
in Scala. But it can be used to test code written in Java.

There's a description of how to use Borachio on Android on my blog: 

I'd be very interested in any feedback!


Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind? 
AIM: paulrabutcher
Skype: paulrabutcher


Re: ANN: Mock Objects on Android with Borachio

by A. Elk » Tue, 15 Mar 2011 10:15:50 GMT

 Good work. I have a couple of comments:

If you have POJOs in your code, you can test them with JUnit using a
standard mocking framework of your choice. The only limitations on
mocking are imposed by the Android system.

Without getting into too much detail, most of the objects in the
Android API can't be mocked. This is known. It's not meant to be test-
hostile, and it's not accidental. I always think that to get anything
useful in a finite amount of time, one has to make tradeoffs.

Some of the class names could have been chosen better, perhaps.
However, their functionality is well-documented.

I think the key thing is that you've produced something useful for
Android developers.


Sponsored Links

Re: Re: ANN: Mock Objects on Android with Borachio

by Paul Butcher » Tue, 15 Mar 2011 19:17:48 GMT


Glad you like it :-)

That's true, of course. In our particular case, however, all of our 
non-Android-specific code is C++, so we have no Java code that doesn't talk to 
Android APIs.

Our C++ code has extensive fully-automated unit and functional tests. We've 
found achieving the same level of test coverage for our Java code to be 
*extremely* difficult. Hopefully the techniques outlined on my blog will remedy 
that somewhat.

That's clearly true, and I'm sure that the Android developers weren't 
deliberately trying to make Android test-hostile. Even if it *feels* like it 
sometimes :-)

I hope so! I'd be very interested to hear your, and others, feedback if/when 
you've had a chance to play with Borachio. It's still very young and I'm sure 
that there is much that could be improved. 


Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind? 
AIM: paulrabutcher
Skype: paulrabutcher


Other Threads

1. About Terms & conditions to submit an application

It's not clear for me the paragraph #10 in "ANDROID DEVELOPER
CHALLENGE TERMS & CONDITIONS". I'm confused and I need understand what
the real meaning on this topic. Google has a serious reputation, but
this paragraph shows something different for Android alliance. The
Android challenge FAQ shows a different point of view of this useless
participant property rights.

If Android challenge will distribute the software platform and
applications for free to "advertise, display, demonstrate, or
otherwise promote the Android platform" what is the real value of
"ownership and intellectual and industrial property rights"?. Android
alliance could distribute the application for free and get revenue
from other sources.
Please note the AND after the "...solely for..... purposes of the

Even worst scenery, if the participant is not selected (position #51
in the challenge), Google could use the participant's application to
promote the android for free and the participant will not have any
chance to compete and get any value in the future  from its work.
I'm a software developer, not an attorney, but the text "perpetual,
irrevocable, worldwide, royalty-free ....." are hard terms for me. The
US patent and trademark office can't grant a patent or trademark on
these terms.

I read the FAQ when I start working on this challenge and I'm confused
with these new terms.
Thank you
Javier Quintana

Extract from FAQ:
Will I continue to own my application after I submit it to the Android
Developer Challenge?
Developers retain all intellectual property and other rights to their
applications while granting Google a license to evaluate and test the
application for purposes of the Challenge as well as a license to
display the application to promote the Android platform. More
information will be provided when we make the Terms and Conditions

Extract from TERMS & CONDITIONS (you need agree this terms before
submit your application).
10. INTELLECTUAL PROPERTY RIGHTS: As between Google and the
Participant, the Participant retains ownership of all intellectual and
industrial property rights in and to the Entry that Participant had
before submission, including the right to distribute the application
commercially at any time. As a condition of entry, Participant grants
Google a perpetual, irrevocable, worldwide, royalty-free, and non-
exclusive license to use, reproduce, publicly perform, publicly
display and create a derivative work from, any Entry that Participant
submits to this Challenge solely for the purposes of allowing Google
to test and evaluate the Entry for purposes of the Challenge AND to
advertise, display, demonstrate, or otherwise promote the Android
platform. Participant also grants Google the right to distribute the
Entry to Judges to test and evaluate the Entry for purposes of the
Challenge. Participant specifically agrees that Google shall have the
right to use, reproduce, publicly perform, and publicly display the
Entry in connection with the advertising and promotion of the Android
platform via communication to the public or other groups, including,
but not limited to the right to make screenshots, animations and video
clips available for promotional purposes.


2. Android's DALVIK failing to build

Below is a snippet of the error message I am getting whenever I try to
clean or Build a new application in Eclipse fro the Android plugin
type of applications.

Does anyone know a way around this. I am using Gusty-Gibon Ubuntu
7.10, and eclipse 3.2.



[2008-04-07 16:54:26 - HelloAndroidApp] invalid constant pool index
...while parsing LocalVariableTable attribute at offset 00000131
...while parsing attributes[1]
...while parsing Code attribute at offset 0000010e
...while parsing attributes[0]
...while parsing methods[0]
...while parsing oco/android/tutorials/R$attr.class
...while processing oco/android/tutorials/R$attr.class
[2008-04-07 16:54:26 - HelloAndroidApp] 6 warnings
[2008-04-07 16:54:26 - HelloAndroidApp] no classfiles specified
[2008-04-07 16:54:26 - HelloAndroidApp] Conversion to Dalvik format
failed with error 1


3. anyone know how to integrate the Wimax drvier, GSM driver, CDMA2000 modem driver

4. need to learn java

5. Can I read files from apk or res\drawable dir

6. Content Provider and notifying changes

7. Plz Help!!