我是Groovy / Grails的新手,我没有找到最新的Grails(3.1.5)的好教程,所以我读了2.1本书(grails 2的权威指南) )因为架构几乎相同。
所以问题在于我无法理解代码的许多部分,例如:
/**
* See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage
instructions
*/
@TestFor(Song)
class SongTests {
void testMinimumDuration() {
// set the Song class up for constraints testing . . .
mockForConstraintsTests Song
// create a new Song
def song = new Song(title: 'Some Title',
artist: 'Some Artist',
duration: 0)
// make sure that validation fails . . .
assert !song.validate()
// make sure that the 'min' constraint failed . . .
assert 'min' == song.errors['duration']
}
}
和宋班:
class Song {
String title
String artist
Integer duration
}
我无法理解许多内容,例如.error(' duration')会做什么?(无法在文档中找到"错误"方法)以及什么& #39; s' min' ?没有" min"类声明中的约束!