How do I test Guice injections?
问题 I gave to Google Guice the responsibility 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 that B is injected correctly? class A { private B b; public A() {} @Inject public void setB(B b) { this.b = b } } Notice that A hasn't got a getB() method and I want to assert that A.b isn't null . 回答1: For any complex Guice project, you should add tests to make sure that the modules can be used