Small question on Spring Cloud contract please.
I am trying to write a basic contract for my Spring Actuator health endpoint.
It is a Spring Webflux 2.4.1 project with JUnit 5 Jupiter 5.7.0 where I am the server (I expose the actuator health endpoint to my clients, hence, I want to write the contract).
Therefore, I imported the actuator jar, and the contract verifier:
<artifactId>spring-boot-starter-actuator</artifactId>
<artifactId>spring-cloud-starter-contract-verifier</artifactId>
I just wrote one simple contract in my resource folder, deleting everything else:
request:
method: GET
url: /actuator/health
headers:
Content-Type: application/json
response:
status: 200
When running mvn clean install, I get :
target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java:[3,17] cannot find symbol
symbol: class Test
location: package org.junit
target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java:[4,17] cannot find symbol
symbol: class Rule
location: package org.junit
target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java:[15,10] cannot find symbol
symbol: class Test
location: class org.springframework.cloud.contract.verifier.tests.ContractVerifierTest
What might be the root cause, and how to fix it please?
Thank you
Apparently you've picked the latest Boot and not the latest Spring Cloud Contract version that assume that you're using JUnit5 and your imports show that you're generating a JUnit4 test class. Either set the testFramework
property to JUNIT5
or migrate to the latest Spring Cloud Contract 3.0.0 plugin that uses JUNIT5 by default.