1

I am using a framework with Serenity BDD (Thucydides), Cucumber and RestAssured. I want to be able to show the Response that I get after performing a request in my Test results HTML page.

Is there any way for doing that?

Thanks!

Daniel Stoica
  • 65
  • 2
  • 2
  • 9

1 Answers1

1

You can pass valid HTML text as a parameter to @Step methods in the step library. This will show up as formatted text in the reports on the step details page.

This can be achieved by creating a dummy @Step method called description that takes a String parameter. At runtime, the tests supply this method with formatted html text as parameter.

@Step
public void description(String html) {
    //do nothing
}

public void about(String description, String...remarks) {
    String html =
    "<h2 style=\"font-style:italic;color:black\">" + description + "</h2>" +
    "<div><p>Remarks:</p>" +
    "<ul style=\"margin-left:5%; font-weight:200; color:#434343; font-size:10px;\">";

    for (String li : remarks) html += "<li>" + li + "</li>";

    html += "<ul></div>";

    description(html);
}

This approach is described more fully here.

MikeJRamsey56
  • 2,779
  • 1
  • 20
  • 34