Response status and type verification error
See original GitHub issueHi,
I have an example project (https://github.com/QAJungle/vertx-testing-example) where I have a Vertx application. I’m doing pact testing.
One of the problems is that when I launch a GetABookByISBNPactTest GetABookByNamePactTest or GetAllBooksPactTest (https://github.com/QAJungle/vertx-testing-example/tree/master/vertx-testing-example-server/src/test/java/com/qajungle/vertx) I obtain the next error, but is random, not alwails fails.
java.lang.AssertionError: 0 - Expected a header 'Content-Type' but was missing 1 - Expected a response type of 'application/json' but the actual type was 'text/plain'
The second error is status assertion error with AddABookPactTest. When I launch tests I obtain the next error:
java.lang.AssertionError: 0 - expected status of 201 but was 200
If you see the pact (https://github.com/QAJungle/vertx-testing-example/blob/master/vertx-testing-example-server/src/test/resources/pacts/add_book_test_consumer-add_book_test_provider.json) and controller code (https://github.com/QAJungle/vertx-testing-example/blob/master/vertx-testing-example-server/src/main/java/com/qajungle/vertx/infrastructure/delivery/vertx/controller/BookController.java#L47) I send 201 status code. In postman I validated it correctly.
You can see the provider and the client in the same repo.
I use: pact-jvm-provider-junit5_2.12 3.6.2 version.
Thanks.
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (5 by maintainers)
Top GitHub Comments
I don’t know much about vert.x, but I can see a difference when running the app versus when the pact test runs.
With the app running:
and when the pact test is run with debug logging enabled:
particularly, the line
headers={content-length=[0]}, contentType=application/json; charset=UTF-8, data=}
shows that the content type header is not being set correctly. It should becontent-Type
notcontentType
.0 - Expected a header ‘Content-Type’ but was missing 1 - expected status of 200 but was 404 2 - Expected a response type of ‘application/json’ but the actual type was ‘text/plain’