热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

addInstrumentedPackage方法不支持指定单一类进行instrumentation

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.


推荐阅读
author-avatar
爱夫777
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有