我是一个 grails 初学者.. 并学习编写单元测试用例
我有 2 个域
class Employee {
String name
String department
static hasOne =[address: Address]
public String toString() {
name
}
}
class Address {
String line1
String line2
Employee employee
static constraints = {
}
}
所以这是我的 AddressControllerTest.groovy
void testSave() {
def address = new Address(line1: "Kaser Road", line2: "Bridage Town")
.addToEmployee(new Employee(name: "monda", department:"IT")).save()
controller.save()
assert model.addressInstance != null
}
给出错误报告
No signature of method: trip.side.Address.addToEmployee() is applicable for argument types: (trip.side.Employee) values: [monda] Possible solutions: setEmployee(trip.side.Employee), getEmployee()
groovy.lang.MissingMethodException: No signature of method: trip.side.Address.addToEmployee() is applicable for argument types: (trip.side.Employee) values: [monda]
Possible solutions: setEmployee(trip.side.Employee), getEmployee()
at trip.side.AddressControllerTests.testSave(AddressControllerTests.groovy:41)
谁能建议我正确的做法。