gpt4 book ai didi

gradle - 如何从命令行使用Gradle包装器2.2.1运行单个单元测试

转载 作者:行者123 更新时间:2023-12-03 12:39:59 24 4
gpt4 key购买 nike

我将Android Studio与Gradle包装器版本2.2.1结合使用,试图在一个测试类中运行所有测试,并在该类中运行特定测试,并尝试使用:

./gradlew  test --tests DownloadsActivityTest

就像文档中建议的一样
-DandroidTest.single=DownloadsActivityTest

但是这些版本都不起作用。

如何使用gradle包装器在命令行中运行单个测试类和单个测试?
 ./gradlew --version

------------------------------------------------------------
Gradle 2.2.1
------------------------------------------------------------

Build time: 2014-11-24 09:45:35 UTC
Build number: none
Revision: 6fcb59c06f43a4e6b1bcb401f7686a8601a1fb4a

Groovy: 2.3.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.7.0_51 (Oracle Corporation 24.51-b03)
OS: Linux 3.17.6-200.fc20.x86_64 amd64

[16:33][j@localhost:~/myHomeDir]$ ./gradlew test --tests DownloadsActivityTest
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debugTest 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.0.3 is ignored for debugTest 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

FAILURE: Build failed with an exception.

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

* Try:
Run gradlew 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: 4.466 secs

最佳答案

从1.0.0版本开始,Android Gradle插件不支持运行单个Android测试。对其的功能请求已提交到https://code.google.com/p/android/issues/detail?id=74196

我知道在1.0版之后的优先级列表中,总体而言,更好的测试支持非常重要,但是我不能确定何时实现。

关于gradle - 如何从命令行使用Gradle包装器2.2.1运行单个单元测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27556238/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com