Hey Jon,
I wanted to throw out another take on the issue, for your enjoyment.
I see two obvious downsides with testing event handlers: 1)
performance, 2) your "action" handlers can junk up your database.
For #2, I can totally see where mocking would be appropriate. But for
all the "display" events, I'm thinking there might be some value in
ignoring the performance hit and actually using that to a better end
than just testing the controller's flow.
For starters, I'm just not sure I see much value in tests that
basically duplicate the controller's "flow" through mock verification.
Kind of seems redundant to me, to no significant benefit (emphasis on
significant). However, if you were to test them directly, you'd get
much more confidence, and also, you'd have the opportunity to see
performance trends over time.
The more I play with Hudson continuous integration, and the more I
simply read and listen to podcasts about CI in general, I'm definitely
seeing how you'd get good value from having the CI server do
performance trending, and then you can start doing things like failing
your "builds" if the delta on your test times exceeds a certain
threshold. So in this respect you take that lemon of performance hit
and turn it into lemonade... i.e. you can get a pretty good idea of
whether your app is performing as expected (admittedly under no load)
over the course of weeks and months.
With the tools these CI servers provide, you would potentially catch
overall system performance problems earlier b/c you'd start seeing
your build times increase, and since they hook into your source
control system, you would have a much easier time of pinpointing the
changes that led to the degradation.
Admittedly, I have zero experience in actually setting up a CI server
to do this, but it's all entirely possible with CF and MXUnit, and
since Luis has made unit testing event handlers with MXUnit so darn
easy, I'm thinking here might be a "win win" kind of deal.
Something to think about, at any rate.
Best,
marc