4

I recently starting learning test driven development, namely MXUnit, and I love the idea's behind it. I can understand the idea of using TDD with stand alone CFC's, but when it comes to using it with OOP based Frameworks, primarily FW/1 and CFWheels, I am not sure how to use MXUnit with the framework CFC's (controllers in FW/1 and Models and Controllers in CFWheels).

Does anyone know where I can find some resources on using MXUnit with Frameworks?

Dave Long
  • 9,569
  • 14
  • 59
  • 89

1 Answers1

3

I can only talk about F/W 1 here as I have not used CFWheels (some info here in another SO question), but in my opinion framework unit testing can be simplified by proper use of a service layer.

The idea is you test service layer objects using MXUnit and leave the framework controllers (for example in FW/1) very lightweight. Essentially the controllers are just passing parameters to the service layer, getting a response back and displaying a view.

The reasoning is that the framework is the least likely place you'll introduce errors - so concentrate your testing on the service object, i.e. the core business logic of your application.

Interestingly, in other non-ColdFusion frameworks (such as Grails) the framework is not tested, tests are created for your model ('domain classes' in grails that model the data) and your service objects, but the framework is assumed to work fine. The idea there - again - is to keep logic out of your controllers and test your service layer and domain model.

I hope that helps in some way.

Community
  • 1
  • 1
Ciaran Archer
  • 12,316
  • 9
  • 38
  • 55
  • That does help. Thank you very much for that. With FW/1 I kind of assumed that the services should handle all the stuff that would need testing. CFWheels, though, uses the framework to handle almost everything. It has a built in ORM to handle the database stuff, and even the views are mostly built by functions, like the form helper functions. – Dave Long Feb 26 '11 at 21:53