在Robolectric 2.2如何指定自定义/ res目录? [英] How do I specify custom /res directory in Robolectric 2.2?
问题描述
我的单元测试,我的Android应用程序住在单独的项目。
My unit tests and my android app live in separate projects.
通过Robolectric 1,我可以指定像这样我的/ res目录位置:
With Robolectric 1, I could specify my /res directory location like so:
public class MyTestRunner extends RobolectricTestRunner {
public MyTestRunner(Class<?> testClass) throws InitializationError {
super(testClass, "../app/AndroidManifest.xml", "../app/res");
}
}
在Robolectric 2.2我如何指定/ res目录位置?
How do I specify the /res directory location in Robolectric 2.2?
推荐答案
我有同样的问题,前一阵子,所有你需要做的就是用你的注解测试类:
I had this same question a while ago, all you have to do is annotate your test class with:
@Config(清单=../应用程序/ AndroidManifest.xml中)
和依赖将有所回升为你从你的清单。
and the dependencies will be picked up for you from your manifest.
PS。还请确保您的注解测试类 @RunWith(RobolectricTestRunner.class)
和你的方法用适当的JUnit批注( @Before
, @Test
, @After
等),以及(以防万一你有没有和忘了)。
PS. also make sure you have annotated your test class with @RunWith(RobolectricTestRunner.class)
and your methods with the appropriate JUnit annotations (@Before
, @Test
, @After
etc.) as well (just in case you haven't and forgot).
这篇关于在Robolectric 2.2如何指定自定义/ res目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!