Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

103
Views
Failure rule for cucumber-jvm

I am writing test suite for Rest APIs using cucumber-java. I was trying to use @Rule, however I found it was not supported by cucumber-jvm. Is there any option to write a rule on step failure ?

I am need to print the request-response on assertion failure (I'm asserting on the http response status), so that I can get an understanding on what went wrong?

Any help on this is much appreciated

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Cucumber-jvm has the @After annotation and you could put something in there but why not simply include the response in the assertion statement failure text?

I use rest-assured to manage my HTTP request-responses. My responses end up in objects of class Response. To get the entire response, I might code this:

response.getBody().prettyPrint()

EDIT

You specified request as well. Given requestSpec is the instance of class RequestSpecification that we initialized with the request values, I use

requestSpec.given().log().all()

to get the request into string form.

So using JUnit assertTrue

assertTrue("REST service x Status Code =" + response.getStatusCode() + 
  ", for request = " + requestSpec.given().log().all() + ",\n response = " +
  response.getBody().prettyPrint(), response.getStatusCode() == 200);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!