Fixed
Status Update
Comments
sl...@google.com <sl...@google.com> #2
Can you please attach the full logcat output to this bug, so we can take a look?
nk...@google.com <nk...@google.com> #3
Yes of course. Here the full logcat. Tested on multiple devices for example Moto G5, Samsung A5 and Nexus 5 (but custom rom)
pa...@mv-nordic.com <pa...@mv-nordic.com> #4
I've tested it today also on the Nexus 5X (Dev Preview 4) and Nexus 5 without custom rom.
sl...@google.com <sl...@google.com>
nk...@google.com <nk...@google.com> #5
Thanks! I will try to see if I can reproduce it on a device. What's interesting though is that the permission seems to be already granted to the package. If you look at your log cat output, right before the exception there is this line: "I/GrantPermissionCallable: Permission: android.permission.WRITE_EXTERNAL_STORAGE is already granted!". What GPC does is to verify that the permission was actually granted for the target context (app under test). One thing that would be interesting if you could run "adb shell pm dump <package> | grep permission" after you ran the tests and paste the outputs here. Thanks.
Description
// classpath 'com.android.tools.build:gradle:2.0.0-alpha9'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
androidTestCompile('com.android.support.test:runner:0.4.1') {
exclude module: 'support-annotations'
}
androidTestCompile('com.android.support.test:rules:0.4.1') {
exclude module: 'support-annotations'
}
What steps will reproduce the problem?
1. Setup example project with a FooService that returns itself via its LocalBinder (see attached sample project for easy setup).
2. Setup a test case using a ServiceTestRule that has 5 methods. Each of these methods call activityRule.bindService() and get the service via the returned 'LocalBinder.getService()' method.
3. Run the androidTest. First test will pass, 4 next tests will fail.
How are you running your tests (via Android Studio, Gradle, adb, etc.)?
Results are the same when running via Android Studio as well as `./gradlew connectedAndroidTest`.
What is the expected output? What do you see instead?
Expected: All 5 tests green. The service should always be shutdown at the end of each test by the ServiceTestRule.
Actual: First test green, other tests red - caused by a NullPointerException at LocalBinder.getService()).
Overall, this means we can't write more than one @Test method for a single service, because all following tests might fail.