Testing creation/delegation in a FrontController...
Posted: Sun Aug 21, 2005 10:06 am
I'm working on my FrontController. I've testing the mapping/dispatch aspect. Now I'm trying to test the delegation aspect. I need to test if it invokes the "invoke" method on the selected class. I can't seem to find a good way to get the mock into the Front Controller.
The FrontController doesn't take any arguments at present so its trivial to kick-off. Adding a factory constructor for the various module controllers that it dispatches to seems wrong/over-complicated just for testing. I guess I could "extract Method" the ModuleController creation and then partialMock it out? I've already used a partial mock before, but it made more sense in that instance I think.
Aren't most FrontControllers fundamentally
How do you get at any of it to test. I've tested the search mapping piece, but in reality that should be a private function and thus I shouldn't be touching it with tests. Invoke (and the constructor) is the only public interface. Yet, I'ld need to test creation of a database connection at least, as well as logging in the common startup tasks. Along with the current creation/invoke problem.
The FrontController doesn't take any arguments at present so its trivial to kick-off. Adding a factory constructor for the various module controllers that it dispatches to seems wrong/over-complicated just for testing. I guess I could "extract Method" the ModuleController creation and then partialMock it out? I've already used a partial mock before, but it made more sense in that instance I think.
Aren't most FrontControllers fundamentally
Code: Select all
class FrontController {
function FrontController() {
// initialize some mapping either from fle or hard-coded
}
function invoke() {
// preform common startup tasks
// search mapping
// invoke selected Action/SubController
}
}