Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

102
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda