lundi 1 juin 2015

Accessing global variable in android.app.application with Robotium test

I am extending android.app.Application in order to save the current user as a global variable, as is suggested in How to declare global variables in Android?

My problem is that when I am running my Robotium tests on my activities, this user object is always null. I've tried setting the object by calling:

    ((Application) getActivity().getApplicationContext()).setCurrentUser(user);

in the setUp() method, but the user object is still null, when I run the tests.

I am totally new to Android testing, so maybe there is a trivial solution to this, but I have been googling the problem, and I haven't been able to find any fixes.

Can anyone help me in the right direction here? Thanks.

Aucun commentaire:

Enregistrer un commentaire