简体   繁体   English

Robolectric-Gradle插件运行单个测试

[英]Robolectric-Gradle plugin running single test

Is it possible to run single tests using Robolectric-Gradle plugin? 是否可以使用Robolectric-Gradle插件运行单个测试?

I tried with this: 我尝试了这个:

./gradlew test -Dtest.single=testName

But it is not working. 但这是行不通的。

Made the same mistake myself. 我自己也犯了同样的错误。 Thats the format for jcandksolutions plug-in (at least that's what I was using). 多数民众赞成在jcandksolutions插件的格式(至少那是我所使用的)。 -Dtest.single=<test name> is not supported by RoboE-Gradle plugin. -Dtest.single=<test name> -Gradle插件不支持-Dtest.single=<test name>

Use --tests <test class name> mechanism. 使用--tests <test class name>机制。 This can be either --tests <classpath of test> or wildcard with --tests *.*Test 这可以是--tests <classpath of test>或带有--tests *.*Test通配符

The method described in the original question does work but you must be working with the latest versions of the robolectric gradle plugin as per docs here 原始问题中描述的方法确实有效,但是您必须按照此处的文档使用robolectric gradle插件的最新版本

So currently in your dependencies section you'll need 因此,目前在您的依赖项部分,您需要

classpath 'org.robolectric:robolectric-gradle-plugin:1.0.1'

If you are updating from 0.xx, as I was, you'll probably need to change the dependencies from androidTestCompile to testCompile to build your tests. 如果像我一样从0.xx更新,则可能需要将依赖项从androidTestCompile更改为testCompile以构建测试。

Then as above 然后如上所述

./gradlew test -DtestDebug.single=<NameOfTestClass>

Will run just your single test (Notice it assumes your test class ends in *Test so you can skip it from the command) 将仅运行单个测试(注意,它假定您的测试类以* Test结尾,因此您可以从命令中跳过它)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM