Spring cloud SpringCloud合同不适用于Surefire 2.20
我正在尝试SpringCloudContact:我的SpringBoot应用程序中有一个端点“/问候语”,它返回“HelloWorld!” 合同内容如下:Spring cloud SpringCloud合同不适用于Surefire 2.20,spring-cloud,maven-surefire-plugin,spring-cloud-contract,Spring Cloud,Maven Surefire Plugin,Spring Cloud Contract,我正在尝试SpringCloudContact:我的SpringBoot应用程序中有一个端点“/问候语”,它返回“HelloWorld!” 合同内容如下: request { method 'GET' url '/greeting' headers { contentType('application/json') } } response { status 200 body([ "content
request {
method 'GET'
url '/greeting'
headers {
contentType('application/json')
}
}
response {
status 200
body([
"content": "Hello, World!"
])
}
我的测试班:
public class ExampleJavaConsumerPactTestIT {
@Before
public void setup() {
RestAssuredMockMvc.standaloneSetup(new GreetingController());
}
@Test
public void aQuickTest(){
}
}
一切正常:如果我将上述合同更改为“内容”:“Hello!”,那么测试将失败
但是,当我将依赖项添加到用户Surefire插件时:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<includes>
<include>**/*IT.java</include>
</includes>
</configuration>
</plugin>
org.apache.maven.plugins
maven surefire插件
2.20
**/*IT.java
然后,我使用错误的契约(内容):“Hello!”)再次运行测试,测试应该失败,但不会失败
有什么问题吗?您的设置错误。生成的测试名为
ContractVerifierTest
,因此您的两个配置文件都没有选择它。只需将***ContractVerifierTest.java
行添加到您的surefire配置中即可。您能将示例发布到某个地方吗?如果没有它,您将很难获得帮助……是吗例如JavaConsumerActTestit您的验证器基类?否则**/*IT.java可能不包括它。@MarcinGrzejszczak我把我的源代码放在这里。基本上,如果我做“mvn清理测试-PCContract测试”,我预计会出现构建失败。@Jeff是的,我已经设置了baseClassForTests。您可以查看github.com/pkid/spring-cloud-contract-with-surefire。