2015-11-06 61 views
3

对于gradle,从命令行执行特定测试应该从版本1.0(或1.1)开始工作,但它不适用于版本2.7。它不适用于gradle从命令行执行特定测试

下面我试着命令:

gradle test --tests com.mk.myfirstapp.MyUT 

gradle这个输出 '未知CMDLINE optiions':

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 
另一个命令

有谁知道这是一个错误还是我的滥用?谢谢。

详情

和我一样的欧宝(下同),但我有一个差的结果。我的gradle出现了什么问题: - ?

 

[email protected]:~/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 

[email protected]:~/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 
+0

的gradle哪个版本您使用的? – Opal

回答

0

--tests选项被正确识别的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 
+2

感谢欧泊的投入,我发现为什么我的差异与他的。 **现在我可以解决**。简而言之,“gradle test --tests classname”报告“无效选项”;但“gradle testDebugUnitTest --test classname”工作正常,并且“gradle testReleaseUnitTest --test classname”也适用。但我无法解释为什么“gradle test”在我的env(一个工作室生成的我的第一个应用程序)中不工作** NOT **。 –

+0

当然,据我看到你已经添加了自定义任务 - 这可能是原因。也许......配置错误。 – Opal

相关问题