I am trying Spring Cloud Contact: I have an endpoint "/greeting" in my spring-boot application, and it returns "Hello World!".
The contract is like below:
request {
method 'GET'
url '/greeting'
headers {
contentType('application/json')
}
}
response {
status 200
body([
"content": "Hello, World!"
])
}
My test class:
public class ExampleJavaConsumerPactTestIT {
@Before
public void setup() {
RestAssuredMockMvc.standaloneSetup(new GreetingController());
}
@Test
public void aQuickTest(){
}
}
Everything works fine: if I change the above contract to "content": "Hello!", then the test fails.
However, when I add in my dependency to user Surefire plugin:
<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>
Then I run the test again with the wrong contract(content": "Hello!"), the test should fail but it does not.
Is there anything wrong?
Your setup is wrong. The generated test is called ContractVerifierTest
so it's not picked by either of your profiles. Just add the <include>**/*ContractVerifierTest.java</include>
line to your surefire configuration.