////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
////


== test-app



=== Purpose


Runs all Grails unit and integration tests and generates reports. The command returns appropriate response codes for embedding with continuous integration servers.


=== Examples


[source,groovy]
----
grails test-app
grails test-app Foo
grails test-app Foo Bar
----


=== Description


Usage:
[source,groovy]
----
grails <<environment>>* test-app <<names>>* [-unit] [-integration] [-continuous]
----

Fired Events:


Executes the Grails unit and integration tests located in the `src/test/groovy` and `src/integration-test/groovy` directories. By default all tests are executed, but you can specify the names of the tests (without the "Tests" or other test type suffix) as argument to the command:

[source,groovy]
----
grails test-app *Foo*
grails test-app *Foo* *Bar*
----

The first example will execute a test called `FooSpec.groovy` whilst the second will execute `FooSpec.groovy` and `BarSpec.groovy` if they exist.

The task of finding tests that match the pattern you provide is passed to Gradle. Take a look at the section in their docs titled link:https://docs.gradle.org/current/userguide/java_plugin.html#test_filtering[Test filtering] for more information.

You can also choose to only run the unit or integration tests:

[source,groovy]
----
grails test-app -unit
grails test-app -integration
----

=== Continuous Testing

[source,groovy]
----
grails
grails> test-app -continuous
----

The `-continuous` option starts Grails' `DirectoryWatcher`. It watches `.groovy` and `.java` files in `grails-app`, `src/main/groovy`, `src/test/groovy`, and `src/integration-test/groovy`. Creating or changing a watched file reruns the tests selected by the command options and test name patterns.

Continuous mode does not run tests when it starts. It is intended for the Grails interactive CLI, where the watcher remains active until you exit the CLI. A one-off `grails test-app -continuous` command exits immediately because `DirectoryWatcher` runs on a daemon thread. Stop interactive continuous testing by exiting the CLI or pressing Ctrl+C.

This is not Gradle's `--continuous` mode. Grails does not pass `--continuous` to Gradle, and `--watch` is not an alias for `-continuous`. Files outside the watched directories, including Java source directories such as `src/main/java`, do not trigger a rerun.

See the link:{guidePath}testing.html[Testing] section for examples on how to combine the different options to target tests.
