How do I test Guice injections?

后端 未结 4 1622
傲寒
傲寒 2020-12-13 04:39

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

4条回答
  •  猫巷女王i
    2020-12-13 05:20

    I don't think you should test private members being set. Better to test against the public interface of your class. If member "b" wouldn't be injected, you'll probably get a NullPointerException executing your tests, which should be plenty of warning.

提交回复
热议问题