Skip to content

miguelchico/test-negative-contract

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

test-negative-contract

To test the services, start it and do:

To check that the error response is correct:

{
  "timestamp": 1481654921954,
  "status": 409,
  "error": "Conflict",
  "exception": "com.example.MyCustomException",
  "message": "CUSTOM_MESSAGE_HERE",
  "path": "/api/v1/xxxx"
}

To test with contracts:

  1. Run mvn clean test

A Build failure message appear:

Tests in error:
  RestTest.validate_negative:28 » IllegalArgument json string can not be null or...

Tests run: 3, Failures: 0, Errors: 2, Skipped: 0

Check the autogenerated class: /test-negative-contract/target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/com/example/external/consumer/RestTest.java

And line 28 is:

DocumentContext parsedJson = JsonPath.parse(response.getBody().asString());

If you inspect that in debug mode, you can see that response.getBody().asString() is empty

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published