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

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -