On Oct 26, 4:39 pm, Endre Stølsvik <stols...@gmail.com> wrote:
> Actually, it is rather typical to NOT use a specific DI-tool when testing,
> but instead doing the "wiring" of code yourself, typically with mock or
> dumyy objects etc. So stating that "Guice is for testing" is actually quite
> strange, bordering on complete display of total misunderstanding of the
> concept.

One more reason to avoid using Guice (or any other DI container) in
the tests is execution speed.

On my computer (C2Q6600) it takes about 5 ms to create a Guice
injector from a couple of modules. On the other hand, if I just create
a couple of objects and mocks and wire them together manually, then
the test can run in less than a millisecond. Using Guice makes such
focused tests 5-10 times slower.

If there are lots of slow tests, then running the test suite will soon
take tens of seconds, after which the programmers will hesitate to run
it after every minor change (http://agileinaflash.blogspot.com/2009/02/
first.html). And when programmers run the tests less often, that in
turn will lead to slower feedback and worse productivity.

Of course some tests are needed, which wire things together with
Guice, just to make sure that the DI configuration is correct (or if
you are not skilled enough to test something in isolation), but the
majority of the tests should not need any frameworks for wiring. If
the tests have so many dependencies that you need a framework for
constructing the system under test just to test one feature, then
that's a test smell that the code has a dependency problem.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-guice@googlegroups.com
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to