I have a seperate Test Project in Eclipse that has been running successfully for a while in both command line and Eclipse. While using Jenkins to run my tests, I've run into the issue where the standard InstrumentationTestRunner does not output in a Jenkins supported xml format. I've read on the internet to use a custom InstrumentationTestRunner. This works in the command line using ADB, but fails in Eclipse when running as Android Test Case.
I've downloaded a custom instrumentation test runner (com.neenbedankt.android.test) and added it to the AndroidManifest like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.testedapplication.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<instrumentation
android:name="com.neenbedankt.android.test.InstrumentationTestRunner"
android:targetPackage="com.testedapplication" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<uses-library android:name="android.test.runner" />
</application>
</manifest>
Here is the error that I get in Eclipse:
[Test Project] is not configured correctly for running tests: A targetPackage attribute for instrumentation android.test.InstrumentationTestRunner in its AndroidManifest.xml could not be found!
You can see that i've set the targetPackage there, so I'm not sure what else I can do?
Add both instrumentation in your AndroidManifest.xml.
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.example.myapp" />
<instrumentation
android:name=".MyRunner"
android:targetPackage="com.example.myapp" />
Then go to Package explorer --> $(Your Test Prject$) --> Run As --> Run configurations --> Android JUnit Test --> $(Your Test Project) --> Instrumentation Runner and select your runner there.
To make eclipse select custom runner by default when doing run as/android junit - simply switch the order in manifest file. Make sure yours is first
<instrumentation
android:name="*.Custom.TestRunner"
android:targetPackage="com.*" />
<instrumentation
android:name="*.InstrumentationTestRunner"
android:targetPackage="com.*" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With