I am new to android junit tests, so please bear with me...
FYI, I'm using IntelliJ IDEA.. And I'm running Mac OSX 10.9 (Mavericks) MacBook Pro Mid 2009
So, I run the test that I want to run, it builds and then after it says that it runs the tests, but before the emulator even does anything, it throws a Runtime Exception:
java.lang.RuntimeException: Exception during suite construction
at android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests.testSuiteConstructionFailed(TestSuiteBuilder.java:238)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)
Caused by: java.lang.NullPointerException
at android.test.suitebuilder.TestMethod.<init>(TestMethod.java:47)
at android.test.suitebuilder.TestSuiteBuilder.build(TestSuiteBuilder.java:189)
at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:379)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4335)
at android.app.ActivityThread.access$1500(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
And it's Test Result simply reads "Failed to create tests" and "testSuiteConstructionFailed".
Here's the testing class and method:
package com.antechdevelopment.mymedapp.screens.screens;
import android.test.ActivityInstrumentationTestCase2;
import android.test.UiThreadTest;
public class ActivityToTestTest extends ActivityInstrumentationTestCase2<ActivityToTest> {
public ActivityToTestTest(Class<ActivityToTest> activityClass) {
super(activityClass);
}
@Override
protected void setUp() throws Exception {
super.setUp();
setActivityInitialTouchMode(false);
/*Other prerequisite code to be executed*/
}
@UiThreadTest //This allows me to interact with the views on the app's main thread...
public void testFoo() {
/*Code to test with...*/
}
}
And my test module's AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.antechdevelopment.mymedapp.tests"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<application>
<uses-library android:name="android.test.runner"/>
</application>
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.antechdevelopment.mymedapp"
android:label="Tests for com.antechdevelopment.mymedapp"/>
</manifest>
Any help would be GREATLY aprecieated!!!
Thanks, Joshua K