Do you want to work on this issue?
You can request for a bounty in order to promote it!
Serenity Restassured test doesn't fail even when response status code is not the expected one #3373
johnysv posted onGitHub
What happened?
I have a simple reatassured code which is below. Here it has to fail when response is not 200 as I have used then().Statuscode(200) in checkstatuscode function. But the test passed.
What did you expect to happen?
No response
Serenity BDD version
4.0.15
JDK version
21
Execution environment
Windows,Chrome
How to reproduce the bug.
I have a simple reatassured code which is below. Here it has to fail when response is not 200 as I have used then().Statuscode(200) in checkstatuscode function. But the test passed. Below is the screen shot too.
<rest.assured.version>5.3.2</rest.assured.version> <serenity.version>4.0.15</serenity.version> jdk version - 21 io.rest-assured-5.3.2
**@Step("When I upload Loss Distribution file {0} for the Cons Unit {1}") public void uploadLossDistribution(final String file, final String consUnit,Object... PathParam){ given().contentType("multipart/form-data") .multiPart("file", new File(file)) .multiPart("id",consUnit) .pathParams("latest-hierarchy-rev-information", latestHierarchyRevision.getVersionHierarchy()) .when().post(resourceUrl,PathParam);
checkStatusCode(200);**
@Step("Then I expect to see {0} as status code") public void checkStatusCode(final int statusCode) { then().statusCode(statusCode); }
Note: The same test fails when I use then().Statuscode(200) as a continuation of post() like below.Not sure why it doesnt fail if I write it as a new method.Please help me to resolve this
@Step("When I upload Loss Distribution file {0} for the Cons Unit {1}") public void uploadLossDistribution(final String file, final String consUnit,Object... PathParam){ given().contentType("multipart/form-data") .multiPart("file", new File(file)) .multiPart("id",consUnit) .pathParams("latest-hierarchy-rev-information", latestHierarchyRevision.getVersionHierarchy()) .when().post(resourceUrl,PathParam).then().statusCode(200);
How can we make it happen?
Work on this myself and propose a PR (with Serenity BDD team guidance)