从Android的工作室,但终端运行测试 [英] Run tests from Android Studio but terminal
问题描述
我使用 decard-gradle这个运行Android Studio中我的JUnit测试。
I'm using decard-gradle to run my junit tests in Android Studio.
如果您从终端测试,这一切都很好,即 ./ gradlew干净的测试
,但如果你想你的测试执行过程中调试,您需要从IDE运行它们(Android的工作室在我的情况)。
It's all fine if you run tests from terminal, i.e. ./gradlew clean test
, but if you want to debug during your tests execution you need to run them from IDE (Android Studio in my case).
为了调试,你需要在你的运行/调试配置添加一个新的摇篮配置 - 干净的测试
- 如果你想只有一个测试类来执行,然后您创建一个JUnit配置,你把'启动另一个配置,并指定gradle这个CONF您在$ p $光伏步创建的。
In order to debug you need to add a new Gradle configuration in your Run/Debug Configurations - clean test
- and if you want the only one test class to execute then you create a JUnit configuration where you put 'launch another configuration' and specify gradle conf you created in prev step.
有时候,我可以看到测试列表我的结果的测试类中,有时候 - 并非如此。我尝试了很多,但还是没有找到办法如何让他们始终显示。这不是真正的唯一debbuging,这也适用于简单的测试运行 - 有时你可以看到测试列表,有时候 - 不是
Sometimes I can see a list of tests within my test class with results, sometimes - not. I experimented a lot but didn't find a way how to make them always show. That's not really about debbuging only, this also applies to simple test run - sometimes you can see a list of tests, sometimes - not.
配置:
Android的工作室0.8.14
gradle这个-2.1
com.android.tools.build:gradle:0.13.2
Configuration: Android Studio 0.8.14 gradle-2.1 'com.android.tools.build:gradle:0.13.2'
推荐答案
在我的理解正确,那么您想运行Android Studio中单独测试。我可以告诉你不同的方式:
When i understood correct, then you like to run single tests in Android Studio. I can tell you different ways:
- 使用的IntelliJ与Android插件,这就是由戴克-支持的gradle的方式。
- 的robolectric-gradle这个-plugin的支持运行测试,但需要大量的手动工作也在最后的过时部分的https://github.com/nenick/android-gradle-template/wiki/Tests-in-Android-Studio---IntellJ
- 切换robolectric支持插件 https://github.com/novoda/gradle-android-测试插件,并在这里是一个戴克项目 https://开头github.com/nenick/android-gradle-template/tree/novoda
- 切换robolectric支持插件 https://github.com/JCAndKSolutions/android-unit-test 其中他额外创建的Android Studio插件。它包含了一个样本,你也可以在这里找到一个样本 https://github.com/nenick/android -gradle模板
Android Studio中
- Use Intellij with Android Plugin, thats the way supported by deckard-gradle.
- The robolectric-gradle-plugin "support" run tests in Android Studio it but need much manual effort also explained here at the last "obsolete" part https://github.com/nenick/android-gradle-template/wiki/Tests-in-Android-Studio---IntellJ
- Switch robolectric support plugin https://github.com/novoda/gradle-android-test-plugin and here is a "deckard project" https://github.com/nenick/android-gradle-template/tree/novoda
- Switch robolectric support plugin https://github.com/JCAndKSolutions/android-unit-test which his extra created Android Studio plugin. It contains a sample and you can also find a sample here https://github.com/nenick/android-gradle-template
这篇关于从Android的工作室,但终端运行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!