59.2 Testing your code

The test command allows you to compile and run tests for your application. Typical usage looks like this:

$ spring test app.groovy tests.groovy
Total: 1, Success: 1, : Failures: 0
Passed? true

In this example, tests.groovy contains JUnit @Test methods or Spock Specification classes. All the common framework annotations and static methods should be available to you without having to import them.

Here is the tests.groovy file that we used above (with a JUnit test):

class ApplicationTests {

    _@Test_
    void homeSaysHello() {
        assertEquals("Hello World!", new WebApplication().home())
    }

}
[Tip] Tip
If you have more than one test source files, you might prefer to organize them into a test directory.

results matching ""

    No results matching ""