【发布时间】:2013-12-06 13:39:14
【问题描述】:
我需要测试一个自定义适配器,它使用 TypedArray 来创建数据。我想为它编写一个仪器测试(即 AndroidTestCase),这当然需要它自己的测试资源。
使用以下结构设置 instrumentTest 子文件夹后:
/ instrumentTest
- src
/ res
- drawable
- layout
# layouts for the tests
- values
# resource values where the TypedArray exists
最初,Android Studio (IntelliJ IDEA 13) 无法识别 R 引用(在PACKAGE_NAME.test.R 下,但在我运行assembleTest 之后,它们会被正确识别。当我执行connectedInstrumentTest 时,测试会因为这个错误而失败:
android.content.res.Resources$NotFoundException: Array resource ID #0x7f040000
at android.content.res.Resources.obtainTypedArray(Resources.java:509)
失败的资源位于PACKAGE_NAME.test.R 下。
帮助?
【问题讨论】:
标签: android intellij-idea android-resources android-gradle-plugin