Hmm... well no, I'm not using coldspring in my tests. I was thinking
that getModel would get that component which has already been
initialised by coldspring - so all its dependencies would already be
injected. But I'm now realising that the fact that the "init"
function is being called indicates this is not the case.
My general problem is I'm trying test my models, which have
dependencies, without mocking those dependencies. I'm struggling to
find examples of how to do this. Maybe it's just not valid approach
and I'm missing the point? Perhaps what I'm trying to do falls under
integration testing?
I'm pretty ignorant when it comes to testing and I appreciate the help!
You are using coldspring for your DI in your app, and that is fine. I would recommend two types of tests: 1) Unit tests for your models (in isolation) and 2) Integration testing for your handlers so you can test EVERYTHING top-down.
This will help you test model objects in isolation by creating it for you and giving it mocking capabilities immediately, so you can just do things like:
etc etc. This will allow you to test the CFC without relying on the dependency injection framework or any other dependency, thus isolation. Then via integration testing (testing your handlers), you can test the whole shabang! How the DI loads, creates, and serves, how the framework creates your handlers, etc