测试和检查之间的差异 [英] Gradle difference between test and check
问题描述
我的 build.gradle
如下:
group 'groupName'
version 'version'
apply plugin: 'java'
apply plugin: 'idea'
sourceCompatibility = 1.8
repositories {
. . .
}
dependencies {
. . .
testCompile group: 'junit', name: 'junit', version: '4.12'
}
在执行 ./ gradlew任务
时处于等级
In Grade when doing ./gradlew tasks
I receive
Verification tasks
------------------
check - Runs all checks.
test - Runs the unit tests.
这两个任务之间有什么区别? ./ gradlew check
的输出与 ./ gradlew test
相同。
What is the difference between these two tasks? The output of ./gradlew check
is identical to ./gradlew test
.
andrewgazelka $ ./gradlew check
> Task :compileJava
warning: Element `SHIFT_UP_THRESHOLD` is set to `UNDEFINED`. This may be ok for this variable.
warning: Element `SHIFT_DOWN_THRESHOLD` is set to `UNDEFINED`. This may be ok for this variable.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 warnings
> Task :test FAILED
MathTest > testX FAILED
java.lang.AssertionError at MathTest.java:40
MathTest > testY FAILED
java.lang.AssertionError at MathTest.java:55
SimulatorTest > testZ FAILED
java.lang.IllegalArgumentException at SimulatorTest.java:71
30 tests completed, 3 failed
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///Users/andrewgazelka/IdeaProjects/RobotCode2018/build/reports/tests/test/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
3 actionable tasks: 3 executed
andrewgazelka $ ./gradlew test
> Task :test FAILED
MathTest > testX FAILED
java.lang.AssertionError at MathTest.java:40
MathTest > testY FAILED
java.lang.AssertionError at MathTest.java:55
SimulatorTest > testZ FAILED
java.lang.IllegalArgumentException at SimulatorTest.java:71
30 tests completed, 3 failed
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///Users/andrewgazelka/IdeaProjects/RobotCode2018/build/reports/tests/test/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
3 actionable tasks: 1 executed, 2 up-to-date
据我了解, ./ gradle test
⊆ ./ grad check
。
推荐答案
Gradle check
任务取决于 test
任务,这意味着在运行检查之前执行测试。 文档指出检查执行了项目中的所有验证任务,包括测试以及任务插件添加到项目中:
The Gradle check
task depends on the test
task which means test is executed before check is run. The documentation states that check performs all verification tasks in the project, including test and also tasks plugins add to the project:
< img src = https://i.stack.imgur.com/M8hjb.png alt =在此处输入图片描述>
如果例如,将 checkstyle 插件添加到您的项目中,您可以运行其任务<$分别使用c $ c> checkstyleMain 和 checkstyleTest
或使用 check
执行完整的项目验证。在这种情况下,任务 test
, checkstyleMain
和 checkstyleTest
而 test
总是只执行单元测试。
If you for example add the checkstyle plugin to your project you can either run its tasks checkstyleMain
and checkstyleTest
individually or execute a full project verification using check
. In this case the tasks test
, checkstyleMain
and checkstyleTest
would be run.
Whereas test
always just executes your unit tests.
这篇关于测试和检查之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!