从命令行运行时,使用库资源的Android单元测试失败

时间:2015-10-28 11:36:29

标签: android unit-testing junit android-testing

内容:

两个模块,android应用程序模块和android库模块。 Application模块的单元测试从Library模块调用类的静态方法,该模块返回Library中定义的资源的资源id。使用“引发:java.lang.ClassNotFoundException:com.example.librarybase.R $ string”进行此调用时,单元测试失败,但仅在从命令行运行时(gradlew test)。从Android Studio运行时,单元测试通过。

设置:

Gradle版本2.4
Android插件版本1.4.0-beta6(repro也在1.3.0)
SDK版本:“Android SDK工具”Rev. 24.4.1
编译Sdk版本23
构建工具版本23.0.1

Android Studio 1.5预览2
Build#AI-141.2343905,建于2015年10月15日
JRE:1.7.0_79-b15 amd64
JVM:Oracle Corporation的Java HotSpot(TM)64位服务器VM

Windows 7 Professional 64位(6.1,Build 7601)

替代方法:

https://github.com/robolectric/robolectric/issues/1737

更多信息:

https://groups.google.com/d/msg/adt-dev/RacBvzBTq9M/5fEv9QD2BwAJ https://code.google.com/p/android/issues/detail?id=191799

0 个答案:

没有答案