tags:

views:

223

answers:

2

The subject says it all. My application gets internet access thanks to the android.permission.INTERNET permission, but my test cases don't while using the instrumentation test runner.

This means I can't test my server IO routines in my test cases. What's up?

Here's my manifest in case it helps you. Thanks!

Sorry about the lack of indents - could not get it working on short notice with this site. Thanks!

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.helloandroid" android:versionCode="1" android:versionName="1.0">

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

<application android:icon="@drawable/icon" android:label="@string/app_name">

<uses-library android:name="android.test.runner" />

<activity android:name=".HelloAndroid" android:label="@string/app_name">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity>

</application>

<uses-sdk android:minSdkVersion="2" />
<instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="qnext.mobile.redirect" android:label="Qnext Redirect Tests" />

</manifest> 
A: 

Hi,

I've compared your manifest file with mine, and it looks about the same. Only difference is that I require minSdkVersion 3, and that I have the uses-permission after the application tag. I don't think that should make a difference.

Are you trying to run on the emulator or on a phone?

Davy Herben
The application runs fine on the phone emulator. The test cases also run on the phone emulator using the supplied instrumentation test runner. The difference is that my application gets internet access, while the test cases do not. I have no idea why. I've tried both positions of the uses-permission tag. No difference, as you suggested.Perhaps the version, but that seems unlikley. I'll give it a try though. Have you tried to use internet access from test cases on the emulator?
Malachii
Just ran the tests again to make sure, and yes, I can run tests which require internet access both on my emulator and on my HTC hero...
Davy Herben
A: 

I'm seeing the same issue, just wondered, was there any headway on this? Did you eventually figure out what the issue was? Thanks, -Jay

Jay