单元测试与Android Studio和摇篮?
我如何添加单元测试到我的机器人工作室(的IntelliJ)容易吗?
How can I add unit tests to my Android projects in Android Studio (IntelliJ) easily?
要更确切的说:我想补充一个文件夹测试code(JUnit 4中),并从那里使用常规的安装JDK(而不是在Android仿真器)执行单元测试。 到目前为止,我添加文件夹测试/爪哇/我的模块,并增加了测试作为源组和JUnit作为测试依赖性:
To be more exact: I want to add a folder with test code (JUnit 4) and execute the unit tests from there using the regular installed JDK (not in an Android emulator). So far I added the folders 'test/java/' to my module and added 'test' as a source set and junit as a test dependency:
sourceSets {
instrumentTest.setRoot('src/test')
}
dependencies {
instrumentTestCompile 'junit:junit:4.+'
// ...
}
当我现在选择的测试/ java文件夹的运行所有测试它给了我一个UnsupportedOperationException。
When I now select Run 'All Tests' on the test/java folder it gives me an UnsupportedOperationException.
我在想什么?你如何运行单元测试的Android项目?
What am I missing? How do you run your unit tests for Android projects?
积分为一个插件,它的工作原理是Infinitest在Eclipse的建议 - 在那里我可以简单地保存类和它的单元测试自动执行。 : - )
Bonus points for a recommendation of a plugin that works like 'Infinitest' in Eclipse - where I can simply save a class and its unit test is automatically executed. :-)
PS:我不想使用https://github.com/JakeWharton/gradle-android-test-plugin由于该插件似乎是德$ P $已经pcated。
PS: I do not want to use https://github.com/JakeWharton/gradle-android-test-plugin since that plugin seems to be deprecated already.
我想答案应该是现在已经在机器人工作室1.1(和当前的摇篮插件)。 他们推出的单元测试支持。 它仍然是实验性的,但比我们的previous这里努力:) 请参见这里。
I think the answer should be now already in Android Studio 1.1 (and current gradle plugin). They introduced unit test support. It's still experimental, but less so than our previous efforts here :) See here.