我正在升级到 Spring Cloud Edgware.RELEASE,我有一个关于如何正确设置 Spring Cloud Contract 测试的基类的问题。以下是我目前通过 Dalston.SR5 工作的基类:
import javax.servlet.Filter;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc;
@RunWith(SpringRunner.class)
@ActiveProfiles("local")
@SpringBootTest(classes = {Bootstrap.class})
@DirtiesContext
public class ConsumerDrivenContractTests {
@Autowired
private WebApplicationContext applicationContext;
@Autowired
private Filter springSecurityFilterChain;
@Test
public void generateTestsFromGroovyFiles() {
}
@Before
public void setup() {
DefaultMockMvcBuilder defaultMockMvcBuilder =
MockMvcBuilders.webAppContextSetup(applicationContext).addFilter(springSecurityFilterChain);
MockMvc mockMvc = defaultMockMvcBuilder.build();
RestAssuredMockMvc.mockMvc(mockMvc);
}
}
升级到 Edgware.RELEASE 后,我的问题import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc;
不再解决,这令人困惑。Spring Cloud Contract 文档指出“默认情况下,Rest Assured 3.x 被添加到类路径中”(参见http://cloud.spring.io/spring-cloud-static/spring-cloud-contract/1.2.0.RELEASE /single/spring-cloud-contract.html#maven-rest-assured),并且给出的示例显示了如何将 Rest Assured 2.x 与<groupId>com.jayway.restassured</groupId>
依赖项一起使用。但是,<artifactId>spring-cloud-starter-contract-verifier</artifactId>
for 1.2.0.RELEASE 引入了<groupId>io.rest-assured</groupId>
依赖项。鉴于文档,我希望这些com.jayway...
罐子能够得到解决。
我的基类方法在升级到 1.2.0.RELEASE 后是否仍然有效,如果是,我是否需要将com.jayway...
依赖项显式添加到我的 pom.xml 文件中?如果是这样,如果文档说明了这一点,将会很有帮助。