Roboelectric,Maven和输出文件夹的困境 [英] Roboelectric, Maven and the plight of the output folder
问题描述
尊敬的真棒社区,
我决定硬着头皮把一些适当的TDD / BDD测试基础设施为我的Android应用程序。我期待融入 Roboelectric 在我的独立测试项目,以prevent我不必启动一个模拟器任何远程的Android-Y。要了解什么是什么我已经导入到我(的Eclipse ADT 3.8)环境RoboElectricSample项目中找到 rel=\"nofollow\">。但是,我已经打了一个问题...一切工作顺顺当当编译明智和我身边工作过的熟悉的 / bin中
, /目标
Maven的Eclipse的对峙与<一个href=\"http://stackoverflow.com/questions/6087690/eclipse-maven-junit-tests-not-compiled-when-running-them/8895652#8895652\">answer这里我不能给予好评不够。
I have decided to bite the bullet and put together some proper TDD/BDD testing infrastructure for my Android application. I am looking to incorporate Roboelectric in my separate test project in order prevent me from having to launch an emulator for anything remotely Android-y. To see what's what I have imported into my (Eclipse ADT 3.8) environment the RoboElectricSample project found here. But I've hit a snag... everything is working swimmingly compilation wise and I've worked around the familiar /bin
, /target
maven-eclipse stand-off with the answer here which I can't upvote enough.
但是,出于示例项目的测试(其中所有87)只有7通,其余翻倒用;
However, out of the sample project's tests (all 87 of them) only 7 pass with the remainder falling over with;
Caused by: java.lang.ClassNotFoundException: com.pivotallabs.R
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:171)
at org.robolectric.AndroidManifest.getRClass(AndroidManifest.java:100)
目前我的的src / test / java下
建立输出位置是相对的在目标/测试类
我的的src / main / JAVA
在目标/班打造的输出位置
。
Currently my src/test/java
build output location is relative at target/test-classes
with my src/main/java
build output location at target/classes
.
有关完整性这里是项目结构;
For completeness here is the project structure;
<一个href=\"http://stackoverflow.com/questions/10091226/change-output-folder-for-android-r-java-in-eclipse-when-using-maven\">This Q&安培; 似乎在暗示我可能会找错了树,但是那是在一年前,现在和M2E-Android插件已经走过了很长的路要走交流。最后,这个问题似乎恰好但可惜没有反映解决我的问题。
This Q&A exchange seems to suggest I might be barking up the wrong tree but that was over a year ago now and the m2e-android plugin has come a long way. Finally, this question seems to reflect my problem exactly but alas with no resolution.
您可以用固定我的构建路径,以获得提供任何帮助/ GEN / R
文件下的Maven的等同于承认生成的来源/ R
AP最多preciated。我想获得示例应用程序启动和运行在交换我的应用程序Roboelectric之前。
Any help you can provide with fixing my build path to get the /gen/r
file to be recognised under the Maven equivalent generated-sources/r
most appreciated. I'd like to get the sample app up and running before switching my app over to Roboelectric.
推荐答案
明白了。
看了这个讨论反对的 M2E-的Android 项目中,我添加了的android.jar
来测试类路径中所描述的这里的和的补充斌\\班
修改测试类路径 rel=\"nofollow\">。我也删除了现在都被拉到一些压倒一切的依赖关系的 Robolectric 的(dexmaker为例)和中提琴,我跑匕首DI'ed code旁边的Android的Mockito测试。
Having read this discussion against the m2e-android project I added the android.jar
to the test class path as described here and added the bin\classes
modification to the test class path as described here. I also removed some overriding dependencies that were now being pulled in by Robolectric (dexmaker for example) and viola, I have Android tests running Dagger DI'ed code alongside Mockito.
生命是TDD现在好多了。
Life is better for TDD now.
上!游戏
这篇关于Roboelectric,Maven和输出文件夹的困境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!