2017-06-20 130 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存在一個問題。我在看他們的問題跟蹤器,並且有很多與這個問題有關的投訴。我知道我沒有給你一個解決方案,但作爲姑息,它可以很好。