[FLOW3-general] No Dependency injection in Tests?
Jacob Floyd
cognifloyd at gmail.com
Tue May 8 00:22:21 CEST 2012
A unit test tests a small section of code (like a single function, or a
particular use of a single function).
A functional test tests a feature including all of the functions, and
dependencies required to make that feature work.
When you are using an object that is injected, you have to replace it with
a mock object when testing. That way, you are not testing the injected
object; you are only testing the particular use of a particular function
(testing a single unit).
For example. Say you have some code that uses FLOW3's new HTTP stuff. You
create a fake/mock http request (or response) handler that is injected in
place of the full-blown http handler. Then it pretends to do http stuff
whenever you are testing something else, without actually using the http
code. That way you're only testing a single unit: a single section of code.
Cheers!
Jacob Floyd
More information about the FLOW3-general
mailing list