How test guice injections?

Posted by yeraycaballero on Stack Overflow See other posts from Stack Overflow or by yeraycaballero
Published on 2010-03-15T14:56:28Z Indexed on 2010/03/15 14:59 UTC
Read the original article Hit count: 493

I gave to Google Guice the responsability of wiring my objects. But, How can I test if the bindings are working well.

For example, suppose we have a class A which has a dependence B. How can I test than B is injected correctly.

  class A {
    private B b;

    public A() {}

    @Inject
    public void setB(B b) {
      this.b = b
    }
  }

Notice A hasn't got a getB() method and I want to assert that A.b isn't null.

© Stack Overflow or respective owner

Related posts about guice

Related posts about testing