unit testing - Mocking mixin classes in Grails -
i having difficulty unit testing controller.
i have following objects:
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 } }
how mock userdetails
method?
i've never done mixin, maybe can test out. in *controllertests
@before void setup() { .. controller.metaclass.userdetails = { new user(username: 'somename') } }
Comments
Post a Comment