Nice work !

There's also Jukito <http://code.google.com/p/jukito/> that simplify test
like you did. There's also an automocking feature using Mockito and well, I
can't live without it now that I use it !

If you already know Guice berry <http://code.google.com/p/guiceberry/>,
Jukito is a lot simplier.

Cheers,

On Thu, Feb 3, 2011 at 12:52 PM, Antoine DESSAIGNE <
[email protected]> wrote:

> Hi everyone,
>
> I've created 2 small classes that really help me writing JUnit tests with
> Guice. I wanted to share them with you, you'll find them attached. See below
> for a sample use.
>
> First you have to create a class that implements the Module interface (that
> should already be done). Its only requirement is to have a no-arg
> constructor.
> public class DummyModule extends AbstractModule {
>  @Override
> protected void configure() {
> bind(String.class).toInstance("TEST");
>  }
> }
>
> Then you write your test:
> @RunWith(GuiceTestRunner.class)
> @WithModules({DummyModule.class})
> public class DummyTest {
> private final String value;
>  @Inject
>  public DummyTest(String value) {
> this.value = value;
> }
>  @Test
> public void test() {
>  Assert.assertEquals("TEST", this.value);
> }
> }
>
> And voilà.
>
> Hope this helps,
>
> Antoine.
>
> --
> 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]<google-guice%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>



-- 
Christian Goudreau
www.arcbees.com

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