Linux command
gradle-test 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Run all tests
gradle test
Run with wrapper
./gradlew test
Run specific test class
gradle test --tests [SomeTestClass]
Run specific test method
gradle test --tests [SomeTestClass.testMethod]
Run tests matching pattern
gradle test --tests '*Test'
Force re-run all tests
gradle cleanTest test
Run tests with continue on failure
gradle test --continue
Dry run without executing
gradle test --test-dry-run
说明
gradle test runs the unit test suite for a Gradle project. It compiles test sources, runs tests, and generates reports. Use --tests to run specific tests by class name, method name, or wildcard pattern. Multiple --tests options can be combined. By default, Gradle skips tests that passed previously unless sources changed.
参数
- --tests _pattern_
- Run tests matching pattern (class, method, or wildcard).
- --continue
- Continue on test failure.
- --test-dry-run
- Simulate without executing tests.
- --info
- Show more test output.
- --rerun-tasks
- Force re-run even if up-to-date.
- -x _task_
- Exclude a task.
FAQ
What is the gradle-test command used for?
gradle test runs the unit test suite for a Gradle project. It compiles test sources, runs tests, and generates reports. Use --tests to run specific tests by class name, method name, or wildcard pattern. Multiple --tests options can be combined. By default, Gradle skips tests that passed previously unless sources changed.
How do I run a basic gradle-test example?
Run `gradle test` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --tests _pattern_ do in gradle-test?
Run tests matching pattern (class, method, or wildcard).