source: trunk/src/templates/artifacts/WebTest.groovy @ 304

Last change on this file since 304 was 304, checked in by duh, 13 years ago
  • added default comments to grails base templates
File size: 2.2 KB
Line 
1/**
2 * @artifact.name@ Web Test
3 *
4 * Description of my web test
5 *
6 * @author  your email (+name?)
7 * @since       2010mmdd
8 * @package     ???
9 *
10 * Revision information:
11 * $Rev$
12 * $Author$
13 * $Date$
14 */
15class @webtest.name.caps@Test extends grails.util.WebTest {
16
17    // Unlike unit tests, functional tests are often sequence dependent.
18    // Specify that sequence here.
19    void suite() {
20        test@webtest.name.caps@ListNewDelete()
21        // add tests for more operations here
22    }
23
24    def test@webtest.name.caps@ListNewDelete() {
25        webtest('@webtest.name.caps@ basic operations: view list, create new entry, view, edit, delete, view') {
26            invoke(url:'@webtest.name.lower@')
27            verifyText(text:'Home')
28
29            verifyListPage(0)
30
31            clickLink(label:'New @webtest.name.caps@')
32            verifyText(text:'Create @webtest.name.caps@')
33            clickButton(label:'Create')
34            verifyText(text:'Show @webtest.name.caps@', description:'Detail page')
35            clickLink(label:'List', description:'Back to list view')
36
37            verifyListPage(1)
38
39            group(description:'edit the one element') {
40                clickLink(label:'Show', description:'go to detail view')
41                clickButton(label:'Edit')
42                verifyText(text:'Edit @webtest.name.caps@')
43                clickButton(label:'Update')
44                verifyText(text:'Show @webtest.name.caps@')
45                clickLink(label:'List', description:'Back to list view')
46            }
47
48            verifyListPage(1)
49
50            group(description:'delete the only element') {
51                clickLink(label:'Show', description:'go to detail view')
52                clickButton(label:'Delete')
53                verifyXPath(xpath:"//div[@class='message']", text:/@webtest.name.caps@.*deleted./, regex:true)
54            }
55
56            verifyListPage(0)
57        }
58    }
59
60    String ROW_COUNT_XPATH = "count(//td[@class='actionButtons']/..)"
61
62    def verifyListPage(int count) {
63        ant.group(description:"verify @webtest.name.caps@ list view with $count row(s)") {
64            verifyText(text:'@webtest.name.caps@ List')
65            verifyXPath(xpath:ROW_COUNT_XPATH, text:count, description:"$count row(s) of data expected")
66        }
67    }
68}
Note: See TracBrowser for help on using the repository browser.