java - Failure to extend an Activity within an Android Test -


i attempting access global variable within test class.

    @test     public void checkinfo()  {     tm1server mtm1server = ((quantum) this.getapplication()).getadminserver().gettm1server();     string username = mtm1server.getusername();     onview(withtext("info")).perform(click());     onview(withtext(username)).check(matches(isdisplayed())); } 

when originially writing code, got error "cannot resolve method 'getapplication()'. original solution add "extends activity" class, allowed test compile, new error appeared:

"java.lang.runtimeexception: can't create handler inside thread has not called looper.prepare()".

thank in advance help!

if has question in future epicpandaforce use

tm1server mtm1server = ((quantum) mactivityrule.getactivity().getapplication()).getadminserver().gettm1server(); 

and not extend activity.


Comments