Fixed
Status Update
Comments
su...@twofortyfouram.com <su...@twofortyfouram.com> #2
This is a regression in the test support library 1.0 / Espresso 3.0.0. The issue does not occur if using the previous version of the testing support library 0.5, Espresso 2.2.2 or Espresso 2.3-alpha
pa...@google.com <pa...@google.com> #3
The ClassNotFoundException is being reported because the class could not be loaded because its base class could not be found. That behavior is correct if the class name has been explicitly specified. However, if the class name was obtained by scanning the path (which I assume is what is happening in this case) then it should ignore class loading errors.
Can you confirm that the test from step 2 is actually run even though a test failure is being reported for the unloadable class?
Can you confirm that the test from step 2 is actually run even though a test failure is being reported for the unloadable class?
su...@twofortyfouram.com <su...@twofortyfouram.com> #4
The test cases are not being run. To prevent runtime crashes, I have the test cases which touch newer APIs configured with @SdkSuppress. The problem is occurring because the new runner is scanning the classpath and blows up whenever it sees something missing.
The same problem will occur with optional dependencies, like how Google Play Services contains MapFragment but the POM doesn't declare a dependency on support-v4. Clients of play services are expected to either not touch MapFragment or include support-v4 before touching the class. I do something similar with one of my own libraries, and anything consuming that library will fail to run tests unless I include an `androidTestCompile` dependency on support-v4.
The same problem will occur with optional dependencies, like how Google Play Services contains MapFragment but the POM doesn't declare a dependency on support-v4. Clients of play services are expected to either not touch MapFragment or include support-v4 before touching the class. I do something similar with one of my own libraries, and anything consuming that library will fail to run tests unless I include an `androidTestCompile` dependency on support-v4.
pa...@google.com <pa...@google.com> #5
I do not understand how the presence of one unloadable class is preventing other tests from being run. The code in TestLoader is explicitly written to detect this situation and defer the reporting of the error until the tests are run so that one unloadable class does not prevent the tests from running.
Could you provide the device side logs from your test run please?
Could you provide the device side logs from your test run please?
ar...@gmail.com <ar...@gmail.com> #6
pa@google.com, another issue closed as duplicate https://issuetracker.google.com/issues/64094195 has logs attached as well as this issue (in the description).
Btw, the workaround for that is to limit scope of the search for the test runner — pass package that contains only tests:
- Either by specifying package by passing instrumentation arguments -e package com.example.tests
- Or by subclassing AndroidJUnitRunner and overriding onCreate and adding package parameter there
Btw, the workaround for that is to limit scope of the search for the test runner — pass package that contains only tests:
- Either by specifying package by passing instrumentation arguments -e package com.example.tests
- Or by subclassing AndroidJUnitRunner and overriding onCreate and adding package parameter there
pa...@google.com <pa...@google.com> #7
The bug referenced in #6 only contains a stacktrace not a full log. Working around it by using package name filtering makes sense because that will remove the name of the unloadable class before it is tried to be loaded.
su...@twofortyfouram.com <su...@twofortyfouram.com>
nk...@google.com <nk...@google.com>
nk...@google.com <nk...@google.com> #9
Pleas give runner:1.0.1-alpha-1 a try and report back if you can still see this issue.
su...@twofortyfouram.com <su...@twofortyfouram.com> #10
After updating to alpha-1, the issue no longer reproduces.
az...@lyft.com <az...@lyft.com> #11
Confirming, Runner 1.0.1-alpha-1 fixes issue, thanks!
Description
Version used: Espresso 3.0.0
What steps will reproduce the problem?
1. Create a class that subclasses something from a newer API level, e.g. MyTileService extends android.service.quicksettings.TileService
2. Create a test case that exercises something different (not the code from step 1).
3. Run the tests on a device running an older version of Android, for example API 19
How are you running your tests (via Android Studio, Gradle, adb, etc.)?
adb
What is the expected output? What do you see instead?
Expected the test from step 2 to run.
Actually the tests fail with this exception
java.lang.ClassNotFoundException: com.twofortyfouram.ui.service.RuleEngineToggleTileService
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:251)
at android.support.test.internal.runner.TestLoader.doCreateRunner(TestLoader.java:76)
at android.support.test.internal.runner.TestLoader.getRunnersFor(TestLoader.java:104)
at android.support.test.internal.runner.TestRequestBuilder.build(TestRequestBuilder.java:808)
at android.support.test.runner.AndroidJUnitRunner.buildRequest(AndroidJUnitRunner.java:481)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:367)
I see the same problem with pulling in Google Play Services, which implements a JobService.
java.lang.ClassNotFoundException: com.google.android.gms.measurement.AppMeasurementJobService
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:251)
at android.support.test.internal.runner.TestLoader.doCreateRunner(TestLoader.java:76)
at android.support.test.internal.runner.TestLoader.getRunnersFor(TestLoader.java:104)
at android.support.test.internal.runner.TestRequestBuilder.build(TestRequestBuilder.java:808)
at android.support.test.runner.AndroidJUnitRunner.buildRequest(AndroidJUnitRunner.java:481)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:367)
at com.twofortyfouram.test.runner.ImprovedRunner.onStart(ImprovedRunner.java:45)