android - testing with mock in robotium -


i using mock test in rbotium. first test fail , test pass. think because of mock not ready test. when add fake test of tests passes.

my fake test:

public void test_showa_homeactionbartabclicked() {         assertequals("","");     } 

all tests:

 public void test_showcategorygameslistfragment_categorylistactionbartabclicked() {         //click on categories action bar tab          getsolo().clickontext(getsolo().getcurrentactivity().getstring(r.string.title_section1));         getsolo().clickontext(getsolo().getcurrentactivity().getstring(r.string.games_title));        assert.asserttrue(getsolo().searchtext("game_category title"));        }     public void test_showcategoryappslistfragment_categorylistactionbartabclicked() {         //click on categories action bar tab         getsolo().clickontext(getsolo().getcurrentactivity().getstring(r.string.title_section1));         getsolo().clickontext(getsolo().getcurrentactivity().getstring(r.string.apps_title));         assert.asserttrue(getsolo().searchtext("app_category title"));      }      public void test_showcategoryappslistrowcountfragment_categorylistactionbartabclicked() {         //click on categories action bar tab         getsolo().clickontext(getsolo().getcurrentactivity().getstring(r.string.title_section1));         getsolo().clickontext(getsolo().getcurrentactivity().getstring(r.string.apps_title));         listview listview = getsolo().getview(listview.class, 0);         assertequals(5, listview.getcount());      }     public void test_showcategorygameslistrowcountfragment_categorylistactionbartabclicked() {          //click on categories action bar tab         getsolo().clickontext(getsolo().getcurrentactivity().getstring(r.string.title_section1));         getsolo().clickontext(getsolo().getcurrentactivity().getstring(r.string.games_title));         listview listview = getsolo().getview(listview.class, 0);         assertequals(5, listview.getcount());      } 

my mock:

protected void setup() throws exception {         super.setup();         getmockrestserver().addmockcallresponsehandler(restcommandfactoryimpl.getinstance().getbaseurl() + "/category"                 , "[ {\"id\":\"1\", \"parentid\":\"12\",\"iconurl\":\"myicon\",\"title\":\"app_category title1\"}," +                 "{\"id\":\"2\", \"parentid\":\"12\",\"iconurl\":\"myicon\",\"title\":\"app_category title2\"} , " +                 "{\"id\":\"3\", \"parentid\":\"12\",\"iconurl\":\"myicon\",\"title\":\"app_category title3\"} ," +                 "{\"id\":\"4\", \"parentid\":\"12\",\"iconurl\":\"myicon\",\"title\":\"app_category title4\"} ," +                 "{\"id\":\"5\", \"parentid\":\"12\",\"iconurl\":\"myicon\",\"title\":\"app_category title5\"}," +                 "{\"id\":\"6\", \"parentid\":\"11\",\"iconurl\":\"myicon\",\"title\":\"game_category title1\"}, " +                 "{\"id\":\"7\", \"parentid\":\"11\",\"iconurl\":\"myicon\",\"title\":\"game_category title2\"}," +                 "{\"id\":\"8\", \"parentid\":\"11\",\"iconurl\":\"myicon\",\"title\":\"game_category title3\"}," +                 "{\"id\":\"9\", \"parentid\":\"11\",\"iconurl\":\"myicon\",\"title\":\"game_category title4\"}," +                 "{\"id\":\"10\", \"parentid\":\"11\",\"iconurl\":\"myicon\",\"title\":\"game_category title5\"}," +                 "{\"id\":\"11\", \"parentid\":null,\"iconurl\":\"myicon\",\"title\":\"بازی ها\"}," +                 "{\"id\":\"12\", \"parentid\":null,\"iconurl\":\"myicon\",\"title\":\"برنامه ها\"}]");          getmockrestserver().addrestcommandtomock("category", new getallcategoriesrestcommand());         getmockrestserver().start();       } 

before adding fake test, test_showcategorygameslistfragment_categorylistactionbartabclicked() not pass , other test pass after adding fake test of them pass. please me

i changed setup n works.

@override protected void setup() throws exception {

    mockrestserver mockrestserver = new mockrestserver();     mockrestserver.addmockcallresponsehandler(restcommandfactoryimpl.getinstance().getbaseurl() + "/category"             , "[ {\"id\":\"1\", \"parentid\":\"12\",\"iconurl\":\"myicon\",\"title\":\"app_category title1\"}," +             "{\"id\":\"2\", \"parentid\":\"12\",\"iconurl\":\"myicon\",\"title\":\"app_category title2\"} , " +             "{\"id\":\"3\", \"parentid\":\"12\",\"iconurl\":\"myicon\",\"title\":\"app_category title3\"} ," +             "{\"id\":\"4\", \"parentid\":\"12\",\"iconurl\":\"myicon\",\"title\":\"app_category title4\"} ," +             "{\"id\":\"5\", \"parentid\":\"12\",\"iconurl\":\"myicon\",\"title\":\"app_category title5\"}," +             "{\"id\":\"6\", \"parentid\":\"11\",\"iconurl\":\"myicon\",\"title\":\"game_category title1\"}, " +             "{\"id\":\"7\", \"parentid\":\"11\",\"iconurl\":\"myicon\",\"title\":\"game_category title2\"}," +             "{\"id\":\"8\", \"parentid\":\"11\",\"iconurl\":\"myicon\",\"title\":\"game_category title3\"}," +             "{\"id\":\"9\", \"parentid\":\"11\",\"iconurl\":\"myicon\",\"title\":\"game_category title4\"}," +             "{\"id\":\"10\", \"parentid\":\"11\",\"iconurl\":\"myicon\",\"title\":\"game_category title5\"}," +             "{\"id\":\"11\", \"parentid\":null,\"iconurl\":\"myicon\",\"title\":\"بازی ها\"}," +             "{\"id\":\"12\", \"parentid\":null,\"iconurl\":\"myicon\",\"title\":\"برنامه ها\"}]");      mockrestserver.addrestcommandtomock("category", new getallcategoriesrestcommand());     mockrestserver.start();     super.setup();  } 

Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -