Command-line Awareness
Gradle standard options
GradleTest is aware of certain command-line parameters and will pass them on to running tests.
-
--rerun-tasks
- All tests will be re-run even if they were previsouly successful. -
--offline
- No dependency checks will be performed and if plugins implements any offline behaviour this will automatically be enabled.
Temporarily overriding Gradle versions
It is very convenient to sometimes to runs the test with a subset of the versions specified in the configuration. This is achievable by passing a gradle property or a system property to Gradle
-DgradleTest.versions=3.5,4.4.1 (1) (2)
1 | If more than one GradleTest task is defined, replace gradleTest with the name of the appropriate GradleTest task. |
2 | List the versions in a commma-separated list. No validation is done on the string. If it leads to invalid Gradle versions the build will fail. |
Selecting what tests to run
GradleTest now purely uses the --tests
command-line parameter, and no longer the -DgradleTest.include
and -DgradleTest.exclude
system properties. It slightly manipulates this for you as you don;t have to remember the name of the generated class file, you simply have to provide the name or parital name of the folder below your src/gradleTest
directory.
So take this folder structure:
src/gradleTest/mytest
build.gradle
src/gradleTest/theirtest
build.gradle
It are these resulting files that you filter what tests you want to run. The first way is to specify a single file
./gradlew gradleTest --tests mytest
If you do
./gradlew gradleTest --tests '*test'
it will run all tests where the folder names contain test
.