JUnit 测试中的 Guice 注入器 [英] Guice injector in JUnit tests

查看:21
本文介绍了JUnit 测试中的 Guice 注入器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Guice,在每个 JUnit 测试类中获得一个新的注入器是否是一个好习惯,因为每个测试类都应该是独立的?

Using Guice, is it a good practice to get a new injector in each JUnit test class, as each test class should be independant?

推荐答案

看一看 Guice Berry.

我现在不推荐使用它(文档真的很糟糕),但是查看他们的方法可以让您清楚应该如何在 jUnit 中完成 DI.

I won't recommend using it now (documentation is really terrible), but looking at their approach can make you think clear about how DI should be done in jUnit.

这篇关于JUnit 测试中的 Guice 注入器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆