Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

100
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda