Got it. Wasn't quite intuitive in the beginning but it seems like a
"Module" is analogous to a <bean-id> in spring. So if you have 25
beans that refers a single bean, "foo", you have a reference for foo
in all those beans. However, to reduce the boilerplate code, Spring
provides autowire(byType or byName). Is there a similar feature in
Guice.

AtUnit looks cool; will check it out. Meanwhile, I added this in the
@BeforeClass in my unit test

injector = Guice.createInjector(new
TemplateModule.Builder().withSession(new Session()).buildModule(),
   new AbstractModule() {
        @Override
        public void configure() {
                requestInjection(this);
    }});


On running the debugger, I can see that template is initialized after
createInjector. However, my test (@Test) method still has a null
reference.

Strange, right? Am I missing something?



On Mar 2, 10:46 pm, Eelco Hillenius <[email protected]> wrote:
> > Why is it not injected?
>
> Because Guice is not in charge of creating your test class instances.
> So you either have to explicitly ask it to inject for you, get a
> reference yourself by using the injector, or use something like
> AtUnit:http://code.google.com/p/atunit/wiki/SupportedContainers
>
> Eelco

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.

Reply via email to