You'd use it where you would create a test-based injector:

Injector injector = Guice.createInjector(Modules.override(...));

On Mon, Sep 26, 2011 at 6:44 AM, Alex opn <[email protected]> wrote:

> Hello,
>
> where would I use this? In the initializations of my tests, I suggest.
>
> On Mon, Sep 26, 2011 at 4:16 AM, Fred Faber <[email protected]> wrote:
> > The common solution here is to use:
> >     Modules.override(productionModule)
> >          .with(testModule);
> > This lets you test without needing to relax your production bindings.
> > Fred
> >
> > On Sun, Sep 25, 2011 at 8:08 PM, rdgoite <[email protected]> wrote:
> >>
> >> Hello.
> >>
> >> I have several Guice modules in my application. Some of them I use for
> >> actual deployment and some of them I use just for testing. Some of the
> >> test modules don't have all the dependencies because I'm limiting the
> >> bindings to things that I want to test and leave others for mocking.
> >> This forces me to make all my @Inject annotations optional. However, I
> >> want to keep injections as strict as its default behavior so that I
> >> get the errors if there are any unresolved/unconfigured components
> >> during deployment.
> >>
> >> Is there a way to indicate optional bindings by module and not through
> >> @Inject(optional=true)? For example, I have a TestModule where I'm not
> >> going to indicate a binding for, say, SomeDependency class because
> >> I'll just mock it for testing. However, say I have ActualModule where
> >> I'll indicate binding of SomeDependency to ActualDependency.
> >>
> >> Thanks.
> >>
> >> --
> >> 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.
> >>
> >
> > --
> > 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.
> >
>
> --
> 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.
>
>

-- 
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