issue setting up a test-module for existing application

148 views
Skip to first unread message

avinash.chugh

unread,
Dec 30, 2010, 8:46:21 AM12/30/10
to Robolectric
I downloaded the sample project and am able to run the tests both from
intellij and from ant. So I tried adding a test-module to an existing
Android application that I'm working on, a simple test to verify the
option menus for an activity. But when I run this test from intellij,
I get the following error:

!!! JUnit version 3.8 or later expected:

java.lang.RuntimeException: Stub!
at junit.runner.BaseTestRunner.<init>(BaseTestRunner.java:5)
at junit.textui.TestRunner.<init>(TestRunner.java:54)
at junit.textui.TestRunner.<init>(TestRunner.java:48)
at junit.textui.TestRunner.<init>(TestRunner.java:41)
at
com.intellij.rt.execution.junit.JUnitStarter.junitVersionChecks(JUnitStarter.java:
183)
at
com.intellij.rt.execution.junit.JUnitStarter.canWorkWithJUnitVersion(JUnitStarter.java:
167)
at
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:
54)

I am happy to provide more details, except I reckon there is something
I am doing that is obviously wrong and am hoping someone can point it
out. I added a test-run parameter as well (-junit4) to see if that
would help, but it didn't. I even checked out your video on
http://wn.com/unit_testing for additional clues, but no luck.

Thanks in advance,
-Avinash Chugh

Carl-Gustaf Harroch

unread,
Dec 30, 2010, 9:22:04 AM12/30/10
to robol...@googlegroups.com
Have you checked the order of imports? Android.jar/maps.jar should
appear after the robolectric jars.

avinash.chugh

unread,
Dec 31, 2010, 12:59:35 AM12/31/10
to Robolectric
Thanks, that seemed to make the difference. On a unrelated note, I was
looking at how to test the menu-item clicks, and it looks like the
TestMenuItem only captures the id-ref into the menu item, and not the
id itself. Whether you use the onOptionsItemSelected() on the Activity
or the setOnMenuItemClickListener() on the MenuItem, you'll need the
id to ensure the next intent is invoked. I need to look at how I can
adjust the MenuLoader to inject the id into the MenuNode (I reckon the
ResourceExtractor could help here).

Cheers,
-Avinash Chugh

On Dec 30, 7:22 pm, Carl-Gustaf Harroch <charr...@gmail.com> wrote:
> Have you checked the order of imports? Android.jar/maps.jar should
> appear after the robolectric jars.
>
> >http://wn.com/unit_testingfor additional clues, but no luck.
Reply all
Reply to author
Forward
0 new messages