This is a repository to show that spring cloud contract has a bug when generating the code to test xml contracts with namespaces.
The repository is confomed by a contract contracts/example.yml
which has a contract with a response body which is an xml which has a name space. Adocker-compose.yml
file that starts a mock service in mountebank and runs the spring test runner container.
Just run
docker-compose up -d
The tests pass and the generated tests:
build/spring-cloud-contract-output/contracts/contracts/ContractVerifierTest.java
validate the xml contract.
assertThat(valueFromXPath(parsedXml, "/customer/email/text()")).isEqualTo("customer@test.com");
The test pass but the generate test validation is wrong
assertThat(valueFromXPath(parsedXml, "/ns1:customer/email/text()")).isEqualTo("");
Also removing the namespaces from the xml fixes the problem.