Specs, Mockito and MowerMock

16 views
Skip to first unread message

The Trav

unread,
Mar 17, 2011, 11:43:16 PM3/17/11
to specs-users
Hey all,

I've just started dipping my toe in scala on android.

I've been using specs + mockito to do some unit testing where I can
avoid the dalvik issues, however I've found this space to be rapidly
decreasing as the android API uses a lot of statics.

I've heard that PowerMock is capable of enhancing Mockito so that it
can mock out statics, finals, basically anything you want.

My google fu seems to be failing me however on whether this
functionality is available from within a specification.

I was thinking something like
class MySpec extends Specification with Mockito with PowerMock {
//tests go here
}

Does it exist? Has anyone thought about it?

etorreborre

unread,
Mar 18, 2011, 12:29:38 AM3/18/11
to specs-users
Hi,

I tried to do that integration with specs some time ago but that
proved to be very hard. Powermock has its own runners and I couldn't
find an easy way to plugin to that.

That being said, I'm working on a project where we have a legacy
library using lots of statics too. Powermock was used at first but we
eventually removed it. It's slow, it's cumbersome to use, it had some
strange interaction when running the full suite.

My advice would be for you to bite the bullet and wrap static calls
behind interfaces that you can mock. I don't know how realistic it is
on the Android but you might get better testing and maintainability
with that.

Eric.

Bill Venners

unread,
Mar 18, 2011, 12:42:55 AM3/18/11
to specs...@googlegroups.com
Hi Trav,

I'd try Borachio:

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

Bill

> --
> You received this message because you are subscribed to the Google Groups "specs-users" group.
> To post to this group, send email to specs...@googlegroups.com.
> To unsubscribe from this group, send email to specs-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/specs-users?hl=en.
>
>

--
Bill Venners
Artima, Inc.
http://www.artima.com

Esko Luontola

unread,
Mar 18, 2011, 4:30:15 AM3/18/11
to specs-users
On Mar 18, 6:29 am, etorreborre <etorrebo...@gmail.com> wrote:
> My advice would be for you to bite the bullet and wrap static calls
> behind interfaces that you can mock.

+1

Anyways you should not mock values you don't own:
http://www.mockobjects.com/2007/04/test-smell-everything-is-mocked.html
Reply all
Reply to author
Forward
0 new messages