320 CHAPTER 7: Rapid Web Development with Grails
Listing 7-7. Replacing the Test with an Incorrect Assertion
void testSomething() {
controller.index()
assert "xyz" == response.text
}
On running the command test-app, Grails runs the test as shown in the following output:
| Loading Grails 2.2.4
| Configuring classpath.
| Environment set to test.....
| Compiling 1 source files.
| Running 1 unit test... 1 of 1
| Failure: testSomething(bookstore.BookControllerTests)
| Assertion failed:
assert "xyz" == response.text
| | |
| | book list
| org.codehaus.groovy.grails.plugins.testing.GrailsMockHttpServletResponse@14cf61d
false
at bookstore.BookControllerTests.testSomething(BookControllerTests.groovy:16)
| Completed 1 unit test, 1 failed in 3210ms
| Packaging Grails application.....
| Packaging Grails application.....
| Tests FAILED - view reports in E:\ModernJava\grails2-workspace\bookstore\target\test-reports
You can generate the report illustrated in Figure 7-18 from the path shown in the last line of the
previous output.