Hi,

I'd like to be able to insert some mocks in the creation of some of my 
service for test purpose. Based on the following answer 
http://stackoverflow.com/questions/483087/overriding-binding-in-guice/531110#531110
 
 on stackOverflow i have the following question:




*>>>but if you're writing unit tests, you probably shouldn't be using an 
injector and rather be injecting mock or fake objects by hand.>>>* 

I do not understand that. The all idea of encapsulating creation is to keep 
it in one place (obviously separating usage from construction). If one 
inject by hand rather than by an injector, then if the constructor change 
you have a problem, you need to propagate that in all the test classes that 
do the creation by hand. Moreover if the constructor are made private as 
per the best practice recommended, that cause a problem too

Hence, my question here is what is the recommended approach to provide some 
mock in unit, that do not break the encapsulation of the creation. I do not 
keep test in the same package as the class. I do BDD. In my test i package 
by Feature. 


Best,

M

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-guice/b17f12f0-e141-49d4-850c-6d59630f4f1c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to