web-dev-qa-db-ja.com

テストとチェックの段階的な違い

私の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 tasksを行うときの成績

Verification tasks
------------------
check - Runs all checks.
test - Runs the unit tests.

これら2つのタスクの違いは何ですか? ./gradlew checkの出力は、./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./gradle check。これは正しいです?

29
Andrew Gazelka

Gradle checkタスクはtestタスクに依存します。つまり、チェックが実行される前にテストが実行されます。 documentation は、checkがプロジェクト内のすべての検証タスクを実行することを示します。テストや、プラグインがプロジェクトに追加するタスクも含まれます。

enter image description here

たとえば、プロジェクトに checkstyle プラグインを追加する場合、そのタスクcheckstyleMainおよびcheckstyleTestを個別に実行するか、checkを使用して完全なプロジェクト検証を実行できます。この場合、タスクtestcheckstyleMain、およびcheckstyleTestが実行されます。
一方、testは常にユニットテストを実行するだけです。

42
UnlikePluto