Testing Acegi Security with mock objects in Grails

I’ve always had the “will” to test my code in Grails, but have had little time to dedicate to writing tests, so at the first sign of difficulty, I’ve abandoned it.  This is bad.  I know it’s bad, but sometimes it can’t be helped.  Part of my difficulties have been due to me trying to get my tests to do something which is not unit testing.  It’s really easy to think you are writing unit tests when in reality, you are writing poor integration tests.  One area in particular that I’ve had trouble is with a small app that tracks time, and produces invoices, and recently I’ve had the luxury of being able to revisit the code and make amends for my previous omissions.   I want to share the revelations I’ve had with you here in the hope that it proves useful to someone.
Continue reading “Testing Acegi Security with mock objects in Grails”