Testing controllers is a thorny subject. Unit testing focuses (or should focus) on small pieces of functionality: objects in isolation, or even just methods in isolation. Testing at the controller level is coarser-grained and tests a lot of moving pieces all at once so it’s not "unit testing", even if you’re mocking absolutely everything (including the FW/1), so you’re into "integration testing" at this point.
You’re right that testing controllers end-to-end is easier / faster than Selenium / WebDriver level testing (well, usually easier) but you have to be very careful since your controllers typically rely on framework behavior and that can be very hard to setup correctly (I.e., to match what really happens in a request). For example, FW/1 relies on `onApplicationStart()`, `onSessionStart()`, `onRequestStart()` all being called appropriately to run the various setup methods. Even a regular request is going to rely on `onRequest()` for all of the processing to occur exactly like a web request. And then `onRequestEnd()` is also invoked automatically.
Since you’re not doing any of that in your test setup, there’s a lot missing from the "model" you’re testing against so your controller might have completely different behavior in the context of a real request (calling `fw.abortController();` and `fw.redirect();` are good examples).
It’s because of that (difference between the test model and the real world model), that I generally don’t recommend testing controllers like this: it’s really hard to get the behavior to match so you can be testing the wrong thing. I’m not saying there’s no value in attempting such testing, just warning that it’s hard and potentially misleading.
That’s also why I’m never attempted to provide a testing mock of the framework itself: providing such a test harness would be misleading, because it would sanction this kind of testing, and I don’t believe I could mock enough of the framework’s behavior accurately enough to ensure that users’ controller-level testing was "doing the right thing".
So, bottom line, I’m glad you’ve found value in doing this but I don’t recommend it :)
Sean Corfield -- (904) 302-SEANAn Architect's View -- http://corfield.org/"Perfection is the enemy of the good."-- Gustave Flaubert, French realist novelist (1821-1880)