You can use:  Module result = Modules.override(new
ProductionModule()).with(new TestModule());
However, the preferred way is to organize bindings in Modules so that
overriding isn't required.

sam

On Fri, Sep 16, 2011 at 12:48 PM, John Butler <[email protected]> wrote:

> I have a default module (HealthStatusModule) that sets up all my
> bindings. One of the binding is as follows:
>
> interface NameProvider;
> class DefaultNameProvider implements NameProvider;
> class TestNameProvider implements NameProvider;
>
> In my HealthStatusModule is set the following;
> bind(NameProvider.class)to(DefaultNameProvider);
>
> What I would like to be able to do is have a TestHealthStatusModule
> that extends HealthStatusModule and does the following:
>
> public void configure(){
>   super.configure();
>   bind(NameProvider.class)to(TestNameProvider);
> }
>
> I read that if TestNameProvider extends DefaultNameProvider than I
> could do the following:
>
> bind (DefaultNameProvider.class)to(TestNameProvider.class);
>
> But what about the case where my test implementation implements the
> interface but does not extend the production class?
>
> What is the standard way the modules are set up for unit testing? Is
> there already a discussion about best practices for this?
>
> --
> 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