我在对控制器进行单元测试时遇到了一些困难。
我有以下对象:
class User {
String username
}
class SecurityMixin {
User userDetails(session) {
User user = new User()
user.username = 'somename'
return user
}
}
@Mixin(SecurityMixin)
class MyController {
def index() {
def username = userDetails(session).username
}
}
我将如何模拟该userDetails
方法?