2015-11-06 114 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