我想在我的spring mvc控制器中進行測試,並且我的applicationContext始終爲null。@WebApplicationContext中的自動化Spring MVC測試不起作用
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.web.WebAppConfiguration
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.ResultActions
import org.springframework.test.web.servlet.setup.MockMvcBuilders
import org.springframework.web.context.WebApplicationContext
import spock.unitils.UnitilsSupport
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
@UnitilsSupport
@WebAppConfiguration
//@ContextConfiguration(classes=Config.class)
//@ContextConfiguration(loader= ApplicationContextProvider.class)
class TimeSheetControllerIt extends TestsSupport {
@Autowired
private WebApplicationContext webApplicationContext; //NULL
//private MockHttpServletRequest mockHttpServletRequest;
private MockMvc mockMvc
private ResultActions resultActions
def setup(){
//this.mockHttpServletRequest = new MockHttpServletRequest();
this.mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
}
我該做什麼?