My build.gradle
is as follows:
group 'groupName' version 'version' apply plugin: 'java' apply plugin: 'idea' sourceCompatibility = 1.8 repositories { . . . } dependencies { . . . testCompile group: 'junit', name: 'junit', version: '4.12' }
In Gradle when doing ./gradlew tasks
I receive
Verification tasks ------------------ check - Runs all checks. test - Runs the unit tests.
What is the difference between these two tasks? The output of ./gradlew check
is identical to ./gradlew test
.
andrewgazelka $ ./gradlew check > 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
From what I understand, ./gradle test
⊆ ./gradle check
. Is this correct?
Check is a task you run from the command line using ./gradlew check in Linux and Mac or gradlew check in Windows. To understand check, know that Gradle has 2 types of tasks: actionable tasks have some action(s) attached to do work in your build. lifecycle tasks are workflow tasks with no actions attached.
By default, Gradle will run all tests that it detects, which it does by inspecting the compiled test classes. This detection uses different criteria depending on the test framework used.
To get an overview of all Gradle tasks in our project, we need to run the tasks task. Since Gradle 5.1, we can use the --group option followed by a group name. Gradle will then show all tasks belonging to the group and not the other tasks in the project.
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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With