How do you get hold of an Android Context for a Junit test from a Java Project?

android, android-context

Solution

What about using AndroidTestCase instead of a JUnit test? AndroidTestCase will provide a Context with getContext() that can be used where it's needed.

Problem

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!)

Original source