Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Command line gradle无法从命令行执行特定测试_Command Line_Gradle_Filter - Fatal编程技术网

Command line gradle无法从命令行执行特定测试

Command line gradle无法从命令行执行特定测试,command-line,gradle,filter,Command Line,Gradle,Filter,对于gradle,从命令行执行特定测试应该可以从1.0版(或1.1版)开始工作,但在2.7版上不工作 我尝试了以下命令: gradle test --tests com.mk.myfirstapp.MyUT gradle输出“未知cmdline选项”: FAILURE: Build failed with an exception. * What went wrong: Problem configuring task :app:test from command line. > Un

对于gradle,从命令行执行特定测试应该可以从1.0版(或1.1版)开始工作,但在2.7版上不工作

我尝试了以下命令:

gradle test --tests com.mk.myfirstapp.MyUT
gradle输出“未知cmdline选项”:

FAILURE: Build failed with an exception.

* What went wrong:
Problem configuring task :app:test from command line.
> Unknown command-line option '--tests'.

* Try:
Run gradle help --task :app:test to get task usage details. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 3.505 secs
另一个命令也一样,如

gradle -Dtest.single=abc test
有人知道这是一个错误或我的误用吗?谢谢

更多详细信息

我做了与欧宝相同的事情(见下文),但我有一个不同的结果。那么,我的格拉德尔怎么了:-

mk@mk-desktop:~/StudioProjects/MyFirstApp$ gradle -v ------------------------------------------------------------ Gradle 2.7 ------------------------------------------------------------ Build time: 2015-09-14 07:26:16 UTC Build number: none Revision: c41505168da69fb0650f4e31c9e01b50ffc97893 Groovy: 2.3.10 Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013 JVM: 1.8.0_51 (Oracle Corporation 25.51-b03) OS: Linux 3.5.0-44-generic amd64 mk@mk-desktop:~/StudioProjects/MyFirstApp$ gradle test --tests BlogFeedEndpointSpec WARNING: Dependency org.apache.httpcomponents:httpclient:4.5.1 is ignored for debug as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages WARNING: Dependency org.apache.httpcomponents:httpclient:4.5.1 is ignored for debug as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages WARNING: Dependency org.json:json:20150407-jdk16 is ignored for debug as it may be conflicting with the internal version provided by Android. In case of problem, please repackage with jarjar to change the class packages WARNING: Dependency org.apache.httpcomponents:httpclient:4.5.1 is ignored for release as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages WARNING: Dependency org.apache.httpcomponents:httpclient:4.5.1 is ignored for release as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages WARNING: Dependency org.json:json:20150407-jdk16 is ignored for release as it may be conflicting with the internal version provided by Android. In case of problem, please repackage with jarjar to change the class packages FAILURE: Build failed with an exception. * What went wrong: Problem configuring task :app:test from command line. > Unknown command-line option '--tests'. * Try: Run gradle help --task :app:test to get task usage details. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 3.574 secs mk@mk-桌面:~/StudioProjects/MyFirstApp$gradle-v ------------------------------------------------------------ 格拉德尔2.7 ------------------------------------------------------------ 构建时间:2015-09-14 07:26:16 UTC 构建编号:无 修订:c41505168da69fb0650f4e31c9e01b50ffc97893 Groovy:2.3.10 Ant:ApacheAnt(TM)版本1.9.3于2013年12月23日编译 JVM:1.8.0_51(Oracle公司25.51-b03) 操作系统:Linux 3.5.0-44-generic amd64 mk@mk-桌面:~/StudioProjects/MyFirstApp$gradle测试——测试BlogFeedEndpointSpec 警告:Dependency org.apache.httpcomponents:httpclient:4.5.1在调试时被忽略,因为它可能与Android提供的内部版本冲突。 如果出现问题,请使用jarjar重新打包以更改类包 警告:Dependency org.apache.httpcomponents:httpclient:4.5.1在调试时被忽略,因为它可能与Android提供的内部版本冲突。 如果出现问题,请使用jarjar重新打包以更改类包 警告:Dependency org.json:json:20150407-jdk16在调试时被忽略,因为它可能与Android提供的内部版本冲突。 如果出现问题,请使用jarjar重新打包以更改类包 警告:Dependency org.apache.httpcomponents:httpclient:4.5.1在发布时被忽略,因为它可能与Android提供的内部版本冲突。 如果出现问题,请使用jarjar重新打包以更改类包 警告:Dependency org.apache.httpcomponents:httpclient:4.5.1在发布时被忽略,因为它可能与Android提供的内部版本冲突。 如果出现问题,请使用jarjar重新打包以更改类包 警告:Dependency org.json:json:20150407-jdk16在发布时被忽略,因为它可能与Android提供的内部版本冲突。 如果出现问题,请使用jarjar重新打包以更改类包 失败:生成失败,出现异常。 *出了什么问题: 配置任务时出现问题:应用程序:从命令行测试。 >未知的命令行选项“--tests”。 *尝试: 运行gradle帮助--task:app:test以获取任务使用详细信息。使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获得更多日志输出。 构建失败 总时间:3.574秒
——测试
选项在gradle 2.7中正确识别:

➜  backend git:(master) gradle -v

------------------------------------------------------------
Gradle 2.7
------------------------------------------------------------

Build time:   2015-09-14 07:26:16 UTC
Build number: none
Revision:     c41505168da69fb0650f4e31c9e01b50ffc97893

Groovy:       2.3.10
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:          1.8.0_05 (Oracle Corporation 25.5-b02)
OS:           Mac OS X 10.10.4 x86_64

➜  backend git:(master) gradle test --tests BlogFeedEndpointSpec 
:compileJava UP-TO-DATE
:compileGroovy UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestJava UP-TO-DATE
:compileTestGroovy UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> No tests found for given includes: [BlogFeedEndpointSpec]

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 6.88 secs

你用的是哪个版本的gradle?感谢Opal的投入,我找到了为什么我的和他的不一样。现在我可以到处工作了。简而言之,“gradle测试——测试类名”报告“无效选项”;但是“gradle testDebugUnitTest——测试类名”可以很好地工作,“gradle testReleaseUnitTest——测试类名”也可以工作。但我无法解释为什么“gradle测试”在我的env(工作室生成了我的第一个应用程序)中不起作用。当然,据我所知,你已经添加了自定义任务——这可能就是原因。也许某事物被误解了。