如何使用Serenity在测试结果中显示REST调用响应?

如何使用Serenity在测试结果中显示REST调用响应?,rest,rest-assured,serenity-bdd,cucumber-serenity,Rest,Rest Assured,Serenity Bdd,Cucumber Serenity,我使用的框架包括Serenity BDD(修昔底德)、Cucumber和Restassed。我希望能够在测试结果HTML页面中显示执行请求后得到的响应 有没有办法做到这一点 谢谢 您可以将有效的HTML文本作为参数传递给步骤库中的@Step方法。这将在步骤详细信息页面的报告中显示为格式化文本 这可以通过创建一个名为description的伪@Step方法来实现,该方法采用字符串参数。在运行时,测试向该方法提供格式化的html文本作为参数 @Step public void description

我使用的框架包括Serenity BDD(修昔底德)、Cucumber和Restassed。我希望能够在测试结果HTML页面中显示执行请求后得到的响应

有没有办法做到这一点


谢谢

您可以将有效的HTML文本作为参数传递给步骤库中的@Step方法。这将在步骤详细信息页面的报告中显示为格式化文本

这可以通过创建一个名为description的伪@Step方法来实现,该方法采用字符串参数。在运行时,测试向该方法提供格式化的html文本作为参数

@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);
}
@步骤
公共无效描述(字符串html){
//无所事事
}
public void about(字符串描述、字符串…备注){
字符串html=
“”+说明+“”+
“备注:

”+ “
    ”; 对于(字符串li:备注)html+=“
  • ”+li+”
  • ”; html+=“
      ”; 说明(html); }

这种方法描述得更全面。

我认为这太宽泛了,但我误解了这个问题。抱歉。