Setting AndroidMock

Hello,

I have an android project and am trying to write tests using AndroidMock. For that I added AndroidMockRuntime.jar as a dependency (using jar option) in my test module. Then I wrote my test as shown below. However as soon as I add the AndroidMockRuntime depencey, I start getting Error-"Test running startedTest running failed: Instrumentation run failed due to 'java.lang.RuntimeException'

Empty test suite".

Any idea on what I am missing here?

Thanks

Apurva


@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);
    }

Please sign in to leave a comment.