Learn Java for Web Development

(Tina Meador) #1

318 CHAPTER 7: Rapid Web Development with Grails


Modify testSomething() as shown in Listing 7-6.


Listing 7-6. Adding the Assertion


1.void testSomething() {
2.controller.index()
3.assert "book list" == response.text
4.}


Now run the test through the Run as ➤ Grails command (test-app), as illustrated in Figure 7-16.


Figure 7-16. The test-app command in Grails


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.....
| Running 1 unit test... 1 of 1
| Completed 1 unit test, 0 failed in 3444ms
| Packaging Grails application.....
| Packaging Grails application.....
| Tests PASSED - view reports in E:\ModernJava\grails2-workspace\bookstore\target\test-reports

Free download pdf