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:

 http://www.paulbutcher.com/2011/03/mock-objects-on-android-with-borachio-part-1/ 
 http://www.paulbutcher.com/2011/03/mock-objects-on-android-with-borachio-part-2/ 
 http://www.paulbutcher.com/2011/03/mock-objects-on-android-with-borachio-part-3/ 

I'd be very interested in any feedback!

--
paul.butcher->msgCount++

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

 http://www.paulbutcher.com/ 
LinkedIn:  http://www.linkedin.com/in/paulbutcher 
MSN: p...@paulbutcher.com
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. 

--
paul.butcher->msgCount++

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

 http://www.paulbutcher.com/ 
LinkedIn:  http://www.linkedin.com/in/paulbutcher 
MSN: p...@paulbutcher.com
AIM: paulrabutcher
Skype: paulrabutcher

-- 



Other Threads

1. Video playback (mediaplayer) always logs ERROR/OsclAsyncFile(12290): OsclAsyncFile::ConstructL!! on Samsung Galaxy S

I'm using a mediaplayer 
(http://developer.android.com/reference/android/media/MediaPlayer.html) 
to playback a video. Everything works fine actually but I noticed that 
on a Samsung Galaxy S, despite that everything seems to run ok, I still 
see errors in the log, which I don't get on Nexus One or HTC Desire. (on 
2.1update1)


For example "ERROR/OsclAsyncFile(12290): OsclAsyncFile::ConstructL!!", which seems to be related to the OpenCore framework, and the origin probably lies somewhere around http://www.netmite.com/android/mydroid/external/opencore/oscl/oscl/osclio/src/oscl_file_async_read.cpp Is anybody else experiencing this on Samsung Galaxy S (I 9000) and having any idea why it occurs / how to avoid it? Maybe anything to pay attention to in the code of the mediaplayer api when using mediaplayer. 07-14 10:40:35.395: VERBOSE/AudioHardwareALSA(12290): ------------------------>>>>>> ALSA OPEN mode 0,device 2 07-14 10:40:35.410: INFO/AudioHardwareALSA(12290): Initialized ALSA PLAYBACK device AndroidPlayback_Speaker_normal 07-14 10:40:35.415: DEBUG/AudioHardwareALSA(12290): Set PLAYBACK PCM format to S16_LE (Signed 16 bit Little Endian) 07-14 10:40:35.415: DEBUG/AudioHardwareALSA(12290): Using 2 channels for PLAYBACK. 07-14 10:40:35.415: DEBUG/AudioHardwareALSA(12290): Set PLAYBACK sample rate to 44100 HZ 07-14 10:40:35.415: DEBUG/AudioHardwareALSA(12290): Buffer size: 4096 07-14 10:40:35.415: DEBUG/AudioHardwareALSA(12290): Latency: 92879 07-14 10:40:36.260: DEBUG/(12290): SISO TEST registering PVMFRecognizerPluginFactory 07-14 10:40:36.260: DEBUG/(12290): SISO TEST registering PVMFRecognizerPluginFactory success 07-14 10:40:36.260: DEBUG/(12290): SISO TEST PVOMA1FFRecognizerFactory::CreateRecognizerPlugin() 07-14 10:40:36.265: DEBUG/(12290): SISO TEST PVOMA1FFRecognizerFactory::CreateRecognizerPlugin() plugin found 07-14 10:40:36.265: DEBUG/(12290): SISO TEST PVOMA1FFRecognizerFactory::DestroyRecognizerPlugin() 07-14 10:40:36.290: ERROR/(12290): ASF_HeaderObjectLoad : ERROR code = 4 07-14 10:40:36.290: ERROR/OsclAsyncFile(12290): OsclAsyncFile::ConstructL!! 07-14 10:40:36.560: WARN/PlayerDriver(12290): Using generic video MIO 07-14 10:40:36.570: ERROR/OsclAsyncFile(12290): OsclAsyncFile::ConstructL!! 07-14 10:40:36.715: ERROR/OsclAsyncFile(12290): 07-14 10:40:36.950: ERROR/VideoMIO(12290): AndroidSurfaceOutput::setParametersSync() VIDEO RENDERER 1 07-14 10:41:10.215: DEBUG/(12290): SISO TEST registering PVMFRecognizerPluginFactory 07-14 10:41:10.215: DEBUG/(12290): SISO TEST registering PVMFRecognizerPluginFactory success 07-14 10:41:10.220: DEBUG/(12290): SISO TEST PVOMA1FFRecognizerFactory::CreateRecognizerPlugin() 07-14 10:41:10.220: DEBUG/(12290): SISO TEST PVOMA1FFRecognizerFactory::CreateRecognizerPlugin() plugin found 07-14 10:41:10.220: DEBUG/(12290): SISO TEST PVOMA1FFRecognizerFactory::DestroyRecognizerPlugin() 07-14 10:41:10.245: ERROR/(12290): ASF_HeaderObjectLoad : ERROR code = 4 07-14 10:41:10.245: ERROR/OsclAsyncFile(12290): OsclAsyncFile::ConstructL!! 07-14 10:41:10.525: WARN/PlayerDriver(12290): Using generic video MIO 07-14 10:41:10.535: ERROR/OsclAsyncFile(12290): OsclAsyncFile::ConstructL!! 07-14 10:41:10.680: ERROR/OsclAsyncFile(12290): OsclAsyncFile::ConstructL!! 07-14 10:41:10.835: ERROR/VideoMIO(12290): AndroidSurfaceOutput::setParametersSync() VIDEO RENDERER 1 07-14 10:41:13.040: INFO/AudioHardwareALSA(12290): Output standby called!!. Turn off PCM device. --

2. Where should I change a ListView's backing data from?

I have a ListView that is filled from my adapter with my custom
views.  Each view has two buttons, one that starts another activity to
edit the contents of that list item and one to delete that item.

My question is where should my ClickEvent handlers for those buttons
be?  Should I put them right in my custom view code since I have all
the information I need? Should I start an ASyncTask that deletes the
item and updates the adapter data and calls onDataSetChanged() etc?

Should all of this be bubbled up through events to my ListActivity?

I could probably make it work at any level, but at what level along
this hierarchy (Activity->ListView->Adapter->ListItemView) is the
proper place to edit/delete backing data for the ListView?

-- 

3. How to compile and install mplayer from source code

4. cara wireless tethering di spic

5. ICS Today, who's coming

6. Setting emulator phone number

7. Stack Exchange Audio Programming Proposal