Setting up AndroidMock in Intellij

147 views
Skip to first unread message

Apurva

unread,
Aug 20, 2012, 11:50:03 AM8/20/12
to androi...@googlegroups.com
Hello,

I am trying to use AndroidMock in my android project that I created in Intellij IDEA 11.1.3. I use the following code to test. However when I try running this test, I get error message "Test running startedTest running failed: Instrumentation run failed due to 'java.lang.RuntimeException'
Empty test suite".

Is there anything that I might be doing wrong here?

Thanks

public class MORouteDataQueryHelperTests extends AndroidTestCase {

    @UsesMocks(DataOperationHelper.class)
    public void testGetAllUSRoutes() throws Exception {
        USRouteDataQueryHelper usRouteQueryHelper=new USRouteDataQueryHelper();

        final Cursor c= AndroidMock.createMock(Cursor.class);
        AndroidMock.reset(c);
        AndroidMock.expect(c.getColumnIndex("NAME")).andReturn(0);
        AndroidMock.expect(c.getString(0)).andReturn("I-95");

        AndroidMock.expect(c.getColumnIndex("DIRECTION")).andReturn(1);
        AndroidMock.expect(c.getString(1)).andReturn("N");

        AndroidMock.expect(c.getColumnIndex("_id")).andReturn(2);
        AndroidMock.expect(c.getInt(2)).andReturn(1);

        DataOperationHelper dbOpHelper= AndroidMock.createMock(DataOperationHelper.class);
        AndroidMock.expect(dbOpHelper.fetchAll("USHighways")).andReturn(c);

        usRouteQueryHelper.dbOpHelper  =  dbOpHelper;
        List<Route> routes=usRouteQueryHelper.getAllRoutes();
        assertTrue(routes != null);
        assertFalse(routes.isEmpty());
        assertTrue(routes.size()==1);
        AndroidMock.verify(dbOpHelper);
    }
}

ns.trueman

unread,
Dec 17, 2012, 3:23:21 AM12/17/12
to androi...@googlegroups.com
I am interested in this as well.
As a workaround project can be configured via Eclipse and then imported to Intellij. Not sure if it works, I am in progress of configuring project under Eclipse, still no success.
Anyway it would be helpful if some instructions for Intellij are prepared, as with 12.0 version it has also powerful support of Android.

--
Sergey N.
Reply all
Reply to author
Forward
0 new messages