CFEasyMock on RIAForge
By: Sean Corfield
As a fan of unit testing, I was interested to hear about a new mock object generator project appearing in the CF world.
I’ve been using Brian Kotek’s ColdMock for a while and I really like how easy it makes it to test CFCs that depend on several other CFCs - because you can create “mock” versions of those CFCs on the fly that return specific values. Mock objects are a good way to provide a consistent environment for your CFCs under test, as well as a way to let your CFCs be tested without them affected the “real” environment (because you can create a “mock” environment which can even include things such as data access objects to fake the whole database layer).
As I blogged recently, I’ve switched from cfcUnit to MXUnit and the mailing list is pretty active. Mike Steele posted that he had ported EasyMock to CFML. My first reaction was “Have you looked at Brian Kotek’s ColdMock project?” and Mike explained that EasyMock isn’t just about creating simple mock objects but about verifying behavior in those mock objects.
Intrigued, I read about EasyMock, a Java project that targets JUnit, and realized the power of being able to create mock objects that expect to be called in certain ways and can, as part of your unit test, actually verify the calls made on them!
I asked Mike to send me a build and I played with it and liked it a lot, pretty much instantly. I sent him some feedback and very soon I got an updated build that incorporated much of my feedback - and a note saying he was already going in that direction. Nice to find a project where I’m on the same page as the author!
You can download the latest build from the CFEasyMock project page on RIAForge. It’s a very simple but very powerful concept that should really help you with your unit testing!


