I am attempting to access a global variable within my 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 this code, I got the error "Cannot resolve method 'getApplication()'. My original solution was to add "extends Activity" to my class, which allowed the test to compile, but a new error appeared:
"java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()".
Thank you so much in advance for any help!
If anyone has this question in the future thanks to EpicPandaForce use
TM1Server mTm1Server = ((Quantum) mActivityRule.getActivity().getApplication()).getAdminServer().getTM1Server();
and do not extend the Activity.
Aucun commentaire:
Enregistrer un commentaire