Fix bug 2056252: android.test.AndroidTestRunnerTest:testRunTestWithNullListener is failing
- Verify mInstrumentation is not null before calling getContext()
diff --git a/test-runner/android/test/AndroidTestRunner.java b/test-runner/android/test/AndroidTestRunner.java
index 00440b43..0d4e1e9 100644
--- a/test-runner/android/test/AndroidTestRunner.java
+++ b/test-runner/android/test/AndroidTestRunner.java
@@ -158,7 +158,7 @@
             mTestResult.addListener(testListener);
         }
 
-        Context testContext = mInstrumentation.getContext();
+        Context testContext = mInstrumentation == null ? mContext : mInstrumentation.getContext();
         for (TestCase testCase : mTestCases) {
             setContextIfAndroidTestCase(testCase, mContext, testContext);
             setInstrumentationIfInstrumentationTestCase(testCase, mInstrumentation);