webtest plugin是用来对Web应用做功能测试的(参考这里)。
安装:grails install-plugin webtest
创建:
grails create-webtest
编写:
利用webTest编写的功能测试样例代码片断如下(用过Selenium的人对如下的代码一定不会觉得陌生)
class MydomainTest extends grails.util.WebTest {
def testMydomainListNewDelete() {
invoke(url:'mydomain')
verifyText(text:'Home')
verifyListPage(0) // <- internal method call for extracting common steps
clickLink(label:'New Mydomain')
verifyText(text:'Create Mydomain')
clickButton(label:'Create')
// more …
}
运行:
grails run-webtest