2017-06-20 60 views
1

我使用的是spring引导,TestNG和PowerMock。SpringBoot TestNg和PowerMock

我扩展了AbstractTestNGSpringContextTests并创建了ObjectFactory作为功能模拟的一部分。所有获得自动装配的bean都被设置为null。也得到例外。

Caused by: java.lang.IllegalArgumentException: class org.springframework.boot.context.ConfigurationWarningsApplicationContextInitializer is not assignable to interface org.springframework.context.ApplicationContextInitializer 
+0

你可以发布一些代码,以便我可以在我的本地重新创建吗? – javaPlease42

回答

0

我有同样的问题,也许一天几个小时后,我决定迁移到Junit的(只是使用PowerMock测试)。一切正常。看来PowerMock + TestNG + Spring存在一个问题。我在看他们的问题跟踪器,并且有很多与这个问题有关的投诉。我知道我没有给你一个解决方案,但作为姑息,它可以很好。