Well, apart from unit tests that use Guice to wire up dependencies no
being unit tests, I was under the impression that guiceberry was the
ticket for this sort of integration test scenario.  Alternately you
can manually register your own request and session scopes in startup
and seed them with fake or mock values.

Regards,
Christian
Sent from my iPhone.

On Feb 8, 2012, at 7:51, Erland <[email protected]> wrote:

> Is there a good way to simulate RequestScoped in a unit test ?
>
> The unit test is not running in a servlet container so when running
> the test case I get an error about:
> 1) No scope is bound to com.google.inject.servlet.RequestScoped.
>
> Ideally I think I'd like RequestScoped to be bound to the scope of the
> current test method in the TestNG test case.
>
> Is there a way to do this without implementing my own scope and
> remapping it to the RequestScoped when running the test case by
> including a module like this in the test case:
>
>    public static class RequestScopeModule extends AbstractModule {
>        @Override
>        protected void configure() {
>            bindScope(RequestScoped.class, new MyMethodScope());
>        }
>    }
>
> Theoretically it might work if I remap it to Scopes.SINGLETON but I
> feel that doing that will risk one test method to affect the outcome
> of the next test method.
>
> Any ideas regarding the best way to accomplish 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