android - searchManager.getSearchableInfo(getComponentName()) returns null only in test -


i have activity searchview under test, works expected tests fail.

@override protected void setup() throws exception {     super.setup();      intent intent = new intent(getinstrumentation().getcontext(),startactivity.class);     startactivity(intent, null, null);                }   @smalltest public void testshouldcreatestartactivity() {     assertnotnull(activity); }     

the test fails because of searchmanager.getsearchableinfo(activity.getcomponentname()) returning null.

searchmanager searchmanager = (searchmanager) activity.getsystemservice(context.search_service); searchableinfo searchableinfo = searchmanager.getsearchableinfo(activity.getcomponentname()); 

very frustrating have working app code tests fail.

i changed test class activityunittestcase activityinstrumentationtestcase2 , works.

read more differences here :

difference between activityunittestcase , activityinstrumentationtestcase2


Comments

Popular posts from this blog

Python Kivy ListView: How to delete selected ListItemButton? -

asp.net mvc 4 - A specified Include path is not valid. The EntityType '' does not declare a navigation property with the name '' -