I need to access and Android context for a JUnit Test.
I have tried using MockContext and extending the AndroidTestCase but each time I get an error saying (stub!)
I need to access and Android context for a JUnit Test.
I have tried using MockContext and extending the AndroidTestCase but each time I get an error saying (stub!)
Each Activity is a subclass of Context, so you must use your Activities when you need Context. The class Context is not something you instantiate from an application.
What about using AndroidTestCase instead of a JUnit test? AndroidTestCase will provide a Context with getContext() that can be used where it's needed.