@tunguski sample code works but it pays to understand how things work. This is just one way to set things up.
@EnableWebMvc
is equivalent to following in a spring configuration file
<mvc:annotation-driven />
Essentially for things to work you need to initialize Spring Mvc and load all your controllers and bean references. So following could be a valid setup as well as an alternate
Following is how you would setup the test class
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath: "classpath:test-context.xml" })
@WebAppConfiguration
public class BaseTest {
@Autowired
WebApplicationContext wac;
private MockMvc mockMvc;
@Before
public void setUp() {
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
}
}
And following could be the spring configuration for the test
<mvc:annotation-driven />
<context:component-scan base-package="com.base.package.controllers" />