作者:爱夫777 | 来源:互联网 | 2024-11-11 15:06
Until 3.0-rc2 I was able to use a custom runner which has overriden createSetup to return a custom I
Until 3.0-rc2 I was able to use a custom runner which has overriden createSetup to return a custom InstrumentingClassLoaderConfig (formerly Setup) that overrides shouldInstrument
1 2 3 4
| public boolean shouldInstrument(ClassInfo info) {
return super.shouldInstrument(info) ||
info.getName().equals("my.package.org.MyActivity");
} |
When updating to 3.0-rc3 I tried to use the new mechanism
1 2 3 4 5
| public InstrumentationConfiguration createClassLoaderConfig() {
return InstrumentationConfiguration.newBuilder()
.addInstrumentedPackage("my.package.org.MyActivity")
.build();
} |
This works for most test classes, but it breaks the test class my.package.org.MyActivityTest, since this class is now also considered to be instrumented, and that leads to
1
| java.lang.IllegalArgumentException: Test class can only have one constructor |
when running the test. It should still to be possible to specify an exact class name for instrumentation, instead of the current comparison made with startsWith.
该提问来源于开源项目:robolectric/robolectric
Sounds like this should be fixed by #1836.