Grails为单元测试提供了很好的支持,提供了大量的mock方法来减轻单元测试的难度和工作。
阅读全文请翻墙。重点摘录,mockConfig的代码示例:
// File: test/unit/SimpleServiceTests.groovy
import
grails.test.*
class SimpleServiceTests extends GrailsUnitTestCase
{
def service
protected void setUp() {
super.setUp()
service = new
SimpleService()
mockConfig('''
<====================================请看这里
simple
{
greeting =
'Hello'
text =
'world.'
}
''')
}
。。。
}