MK *_*oho 8 command-line filter gradle
对于gradle,从命令行执行特定测试应该从版本1.0(或1.1)开始工作,但它不适用于版本2.7.
我试过下面的命令:
gradle test --tests com.mk.myfirstapp.MyUT
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
对于另一个命令也一样
gradle -Dtest.single=abc test
Run Code Online (Sandbox Code Playgroud)
有谁知道这是一个错误或我的滥用?谢谢.
更多细节
我和欧宝(下图)做了同样的事,但我有不同的结果.我的朋友有什么问题: - ?
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
我还收到错误:未知的命令行选项“--tests”。
事实证明,在错误发生后运行建议的命令很有用。在你的情况下:
运行 gradle help --task :app:test 以获取任务使用详细信息。
我在一个多模块 Android 项目中,它尝试运行的第一个项目/任务注册为:
Type
Task (org.gradle.api.Task)
Description
Run unit tests for all variants.
Run Code Online (Sandbox Code Playgroud)
对我来说,问题是此任务在所有变体上运行,并且该--tests参数在org.gardle.api.Task.
Android 的一个解决方案是运行一个特定的变体任务,例如testRelease,它注册为:
Type
AndroidUnitTest (com.android.build.gradle.tasks.factory.AndroidUnitTest)
Options
--debug-jvm Enable debugging for the test process. The process is started suspended and listening on port 5005.
--fail-fast Stops test execution after the first failed test.
--tests Sets test class or method name to be included, '*' is supported.
Description
Run unit tests for the release build.
Run Code Online (Sandbox Code Playgroud)
./gradlew testRelease --tests '*.SomeFilter'因此为我工作。
--tests选项在 gradle 2.7 中被正确识别:
\xe2\x9e\x9c backend git:(master) gradle -v\n\n------------------------------------------------------------\nGradle 2.7\n------------------------------------------------------------\n\nBuild time: 2015-09-14 07:26:16 UTC\nBuild number: none\nRevision: c41505168da69fb0650f4e31c9e01b50ffc97893\n\nGroovy: 2.3.10\nAnt: Apache Ant(TM) version 1.9.3 compiled on December 23 2013\nJVM: 1.8.0_05 (Oracle Corporation 25.5-b02)\nOS: Mac OS X 10.10.4 x86_64\n\n\xe2\x9e\x9c backend git:(master) gradle test --tests BlogFeedEndpointSpec \n:compileJava UP-TO-DATE\n:compileGroovy UP-TO-DATE\n:processResources UP-TO-DATE\n:classes UP-TO-DATE\n:compileTestJava UP-TO-DATE\n:compileTestGroovy UP-TO-DATE\n:processTestResources UP-TO-DATE\n:testClasses UP-TO-DATE\n:test FAILED\n\nFAILURE: Build failed with an exception.\n\n* What went wrong:\nExecution failed for task ':test'.\n> No tests found for given includes: [BlogFeedEndpointSpec]\n\n* Try:\nRun with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.\n\nBUILD FAILED\n\nTotal time: 6.88 secs\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
2877 次 |
| 最近记录: |