You can use the Rails approach to testing mails: monkey-patch mail send code during test setup to place all mail instances that should have been delivered into a globally accessible array, this way you can do asserts on that array.
Don't ask me for exact implementation details because I'm not into grails, but the general principle is this:
if you have a class MyMailThingy
which has a deliver
method on it's instance which performs the mail delivery (presumably mail subject, body etc are attributes on this object), then monkey patch:
class MyMailThingy
# same as `cattr_accessor :mock_queue` under rails
def self.mock_queue; @@mock_queue; end
def self.mock_queue=(arg); @@mock_queue=arg; end
def deliver
self.class.mock_queue ||= []
self.class.mock_queue << self.dup
self
end
end
and then in your tests you can assert on MyMailThingy.mock_queue
how many mails have been sent, assert on their bodies, subjects, to/from fields etc without sending actual mails