I'm testing changePassword() method. I'm checking by giving a wrong password firstly, then giving parameters correctly on the second part. However, for the wrong password, it's giving me error for the body(). If I log().body() it doesn't print out anything, but the status code matches. If I do body("errors[0]",equalTo("Wrong password")) it shows me error for this line saying "Expected response body to be verified as JSON
, HTML
or XML
but no content-type
was defined in the response."
given().
contentType("application/json").
header("ID", "2501").
param("newPass", "pass2017").
param("oldPass", "pass2015"). // wrong password
when().
put("/v1/password").
then().
statusCode(400).
//log().body();
body("errors[0]",equalTo("Wrong password"));
Also for correct parameters, it says Expected status code <200> doesn't match actual status code <400>.
I don't know what parameters I could have given wrong, it seems everything is OK. Can anyone explain me what could be wrong in these pieces of code?
given().
contentType("application/json").
header("ID", "2501").
param("newPass", "pass2017").
param("oldPass", "pass2016").
when().
put("/v1/password").
then().
statusCode(200).
//log().body();
body("content.response", equalTo(true)) ;
Thanks!
UPDATE: I checked this method on Swagger, it works fine.