Fixed
Status Update
Comments
sl...@google.com <sl...@google.com> #2
The link in the above description doesn't work external to google, expanded link: https://issuetracker.google.com/issues/73450636
nk...@google.com <nk...@google.com> #3
This will be fixed in the next release.
pa...@mv-nordic.com <pa...@mv-nordic.com> #4
I don't know the inner workings of this, but there seems to be a connection to Issue 36949180 : ServiceTestRule.bindService() returns null on 2nd invocation.
Issue 36949180 has a workaround where you repeat "serviceRule.bindService(intent)" until it no longer returns null. I tried the FooServiceTest in multiple-service-calls-test.tgz in my own project setting and test 2 to 5 failed. However, all tests succeeded after changing the bindService() method to repeatedly bind inside a while loop until the returned binder is not null.
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.