Robolectric @Config path value for manifest

不想你离开。 提交于 2019-12-06 03:02:49

问题


I am trying to run robolectric unit test but I am getting error as AndroidManifest.xml not found on path. Can anyone give me an example path of @Config manifest value. Is it relative path or absolute one?

Thanks in advance


回答1:


If you are using maven to run your tests you can set as follows:

@Config(manifest = "../app/AndroidManifest.xml")
@RunWith(RobolectricTestRunner.class)
public class SomeTestCase { ... }

Please note that if you are using Android Studio/Intellij and want to run your tests within the IDE you will have to make a change in the Run configuration.

In Run->Edit configuration->Defaults->JUnit->Working directory set the value $MODULE_DIR$ and Android Studio will set the relative path in all junits just like Maven.

This worked for me however if the annotation fails, you can also create a file called "org.robolectric.Config.properties" and place it on your classpath.
The file should contain something like the following: "manifest: ./app/AndroidManifest.xml"

More information can be found here: Configuring Robolectric 2.0
A simple configuration using maven can be found here: Simple Robolectric



来源:https://stackoverflow.com/questions/17441793/robolectric-config-path-value-for-manifest

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!