I’ve got a service, which is using sendJMSMessage method which is provided by jms-grails plugin.
I want to write some unit tests, but I’m not sure how to “mock” this method, so it just does nothing at all.
Any tips?
I’ve got a service, which is using sendJMSMessage method which is provided by jms-grails
Share
You can metaClass the method to have it return whatever you want.
I like to have a
wasCalledflag when I’m returningnullfrom a metaClassed method because I don’t particularly like asserting that the response isnullbecause it doesn’t really assure that you’re wired up correctly. If you’re returning something kind of unique though you can do without thewasCalledflag.In the above example I used 1 String parameter but you can
metaClassout any number/type of parameters to match what actually happens.