The Gradle test task runs your automated tests to check if your code works correctly. It helps catch mistakes early.
Gradle test task in JUnit
gradle test
This command runs all tests in your project using the default test framework (like JUnit).
You can customize the test task in your build.gradle file to change how tests run.
gradle test
gradle test --info
gradle test --tests "com.example.MyTestClass"gradle test --tests "com.example.*"This Gradle build script applies the Java plugin, configures the test task to use JUnit Platform, and sets test logging to show passed and failed tests.
When you run gradle test, Gradle will find and run all JUnit tests and show which tests passed or failed.
plugins {
id 'java'
}
test {
useJUnitPlatform()
testLogging {
events 'passed', 'failed'
}
}
// Run with: gradle testMake sure your test classes and methods follow JUnit naming conventions so Gradle can find them.
You can customize the test task in build.gradle to change test behavior, like adding system properties or changing logging.
Use gradle test --scan to get a detailed test report online (requires Gradle Enterprise).
The Gradle test task runs your automated tests to check code correctness.
You run it with gradle test and can customize it in build.gradle.
It helps catch bugs early and shows which tests passed or failed.