春季MVC(版本5)可以与黄瓜放心使用吗?

时间:2019-03-28 14:12:15

标签: java spring-mvc cucumber rest-assured

我正在尝试使用黄瓜,放心的弹簧和5号弹簧来设置BDD测试。由于weapplicationcontext是必需的,所以我经常遇到错误。 weapplicationcontext没有实例化。我仍在使用MockMvcBuilders.webAppContextSetup(this.webApplicationContext).build()为空。

我尝试添加@ContextConfiguration@WebAppConfiguration

@Configuration
@ContextConfiguration
@WebAppConfiguration
@Import({AppConfig.class, TestConfig.class})
@ActiveProfiles({"local", "test"})
public class TestSetup {

    protected WebApplicationContext webApplicationContext;

    @Given("^the web context is set$")
    public void the_web_context_is_set() {
        //ServletRequest servletRequest = new MockHttpServletRequest();
        //AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
        //ctx.register(BookkeepingAppConfig.class);
       // ctx.setServletContext(servletRequest.getServletContext());
       // this.webApplicationContext = ctx;
        TestContext.getInstance().setMockMvc(MockMvcBuilders.webAppContextSetup(this.webApplicationContext).build());
    }

0 个答案:

没有答案