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 much 80%+ coverage on all my Java code… It’s a bit tricky to mock out UnknownHostException, but I can live it. So what strange maniacal thing overcomes me when I start working on Grails apps that I think myself immune from testing?

Grails Productivity. It’s like a drug.You barely ever need to restart the Grails test harness these days, so you keep on adding feature after feature to your app, clicking refresh, testing it out, getting excited. “Yup. That’s done. Next feature. Oh, must get back to those test cases. Dierk would kill me.” But in the haze of seeing your app coming together so quickly, your tests folder grows with more and more empty stubs.

So I have several inspiring friends who are hardcore but pragmatic testing folk. Jason is even a 100% coverage guy - no exceptions (!?). And it’s really starting to bug me that I’m so casual about the after hours stuff I do on Grails.

So here’s the deal. I’m coming clean and declaring this month is “MockFor(March)” for Glen. I’m going to be posting only on Grails Unit testing for the whole month. Not even Grails integration tests. Just unit tests.

Grails Unit testing in Intellij

Why just unit tests? Two reasons: (1) Because I want to be able to run these bad boys straight from Intellij and have them run in under a second each. Intellij 7.0.3 will have in-IDE coverage markers for Groovy test cases, so I can easily tell what’s covered and what isn’t…

And (2) I really want to learn more about the dynamic side of Groovy - in particular ExpandoMetaClass. Focussing on unit testing means I’ll need to mock out some tricky stuff to ensure I’m just testing the Class Under Test (CUT). So a doubly good learning exercise.

If you’d like to follow along, I’m going to be using Gravl (the software that powers this blog) as my test app. The source code is all on googlecode, so you can always find the nitty gritty up there, but I’ll blog up the highlights here.

It’s gonna be a fun month. Hopefully along the way we’ll all increase our Grails testing kung-fu.