1
其实我正在为@Autowired AppLog
编写junits。如何模拟Junits的应用程序
并使用this.applog.logInfo("field",+object.getFieldName())
,他们正试图打印值。
我没有得到如何嘲笑这件事。
我已经在使用@RunWith(SpringRunner.class)
。
PowerMock在这种情况下可以提供帮助吗?如果有人能帮忙,我会很感激。
其实我正在为@Autowired AppLog
编写junits。如何模拟Junits的应用程序
并使用this.applog.logInfo("field",+object.getFieldName())
,他们正试图打印值。
我没有得到如何嘲笑这件事。
我已经在使用@RunWith(SpringRunner.class)
。
PowerMock在这种情况下可以提供帮助吗?如果有人能帮忙,我会很感激。
在Spring中,我们有一个知道类[ReflectionTestUtils][1]
的类,如果您正在测试具有依赖关系的类,可以使用它。在这种情况下,我们有applog autowired。
所以,我们下@Before
标注方法可以定义:
ReflectionTestUtils.setField(instanceOfClassWeAreTesting,"appLog",mockedApplogInstance)
。
希望有助于未来有人面对任何问题。
这个我已经实现了我自己和works.Will为其他解决方案感到高兴 –