Browsing articles from "March, 2008"
Mar
27
2008

MockFor(March): Unit Testing Grails Services

Ok. We’ve had a look at Taglibs and Controllers, it’s time to take a looks at Services. Let’s start with a simple one… My NotificationService gets called when people post new comments. But before we send a notification, we check to see whether notifications are turned on for the blog in question. This requires a little navigation of the object graph… boolean isEmailNotifyActive(Comment comment) { BlogProperty bp = comment.blogEntry.blog.blogProperties?.find { prop -> prop.name == “emailNotify” [...]

Mar
12
2008

MockFor(March): Unit Testing Grails Controllers

Alrighty team, it’s time for a grab-bag of Grails Controller unit testing fragments to get you started. Most of these have been shamelessly stolen from the Graeme’s Grails.org wiki sample code, and spiced up to suit. On the testing board today is our LoginController, since it’s pretty low hanging fruit for simple test cases that showcase the common stuff you’re likely to want to do. Let’s start with the index method, that’s gotta be a [...]

Mar
7
2008

MockFor(March): Unit Testing Grails Taglibs

Alrighty, I’m starting a little series this month exploring Grails unit tests. Some of you guys are already further along this road than me, so if you have smarter ways of doing things, don’t hesitate to add comments. My Grails testing kungfu is pretty white belt. We’re starting the journey with taglibs, since they typically front pretty minimal logic, and often don’t need too much mocking. Probably the only things you *have* to mock out [...]

Mar
5
2008

Hanging out with James Gosling in Canberra

In a very cool set of circumstances I had the chance to hang out with James Gosling this afternoon at a Canberra Q&A session. There were only six of us there, and we had an hour with an open agenda: ask whatever you like! So I did… JAG is one very loveable character. The hardcore software engineer who made it big, changed the world, and still remains a nice guy. I asked him a bunch [...]

Mar
4
2008

MockFor(March): Overcoming Grails testing inertia

A Java guy, Rails guy, and Grails guy walk into a bar… Or so the gag begins… but whatever they talk about, one things for sure, at the end of the day, the Grails guy probably ends up with a bunch of stubs in their tests folder. Well as least I do. It’s weird. I’m mostly an enterprise guy, working at the big end of town. Looking at my test metrics onsite yesterday, I’m pretty [...]

Glen Smith

About Glen

Co-author Grails in Action