+21
−0
Loading
Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more
If your class requires a Context instance make it a constructor argument. Then create a static factory method that calls Globals.getContext(). The result can then be passed to the constructor. This allows testing individual classes using test doubles by directly invoking the constructor and not having to deal with Globals. For integrated tests spanning multiple classes you might have to use Globals.setContext().