我正在尝试在我的 spring mvc 控制器中进行测试,而我的 applicationContext 始终为空。
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();
}
我必须做什么?