java - 使用 Jersey 框架进行测试,并使用 Extentreports 进行报告

标签 java unit-testing reporting jersey-2.0 extentreports

我是测试新手,需要使用extentreports报告测试结果,

下面是测试代码:

public ExtentReports reports;
public ExtentTest logger;

public ModelTests() {
    reports = new ExtentReports("acceptanceTest\\reports\\Report.html");
}

@Test
public void searchModelTest() throws JSONException, URISyntaxException {
    JSONObject jsonResponse = searchModel();                
    logger = reports.startTest("Test");
    logger.log(LogStatus.PASS, "Success");
    assertEquals("SOLAR SLEEVE 2014", jsonResponse.getString("modelName"));
    logger.log(LogStatus.FAIL, "Failure");
    reports.endTest(logger);
}

我没有看到生成任何报告。

extentreport 可以与 jersey 框架一起使用吗?我看过 selenium 示例。

帮助将不胜感激。

最佳答案

这是您应该遵循的 list :

  1. 创建 ExtentReports 的新实例。

    ExtentReports extent = new ExtentReports(file-path, replaceExisting);

  2. 通过 startTest 方法命名并描述实例。请记住,您现在正在创建 ExtentTest 的新实例。

    ExtentTest test = extent.startTest("Test Name", "Sample description");

  3. 根据 ExtentTest 实例记录结果。

    test.log(LogStatus.PASS, "Step details");

  4. 结束测试。

    extent.endTest(test);

  5. 最后将所有内容写入文档

    extent.flush();

此外,这里是专门针对那些通过 Maven 实现的文档。

ExtentReports | Maven Documentation

...

关于java - 使用 Jersey 框架进行测试,并使用 Extentreports 进行报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35947898/

相关文章:

c# - 为 VS UT 断言类创建自定义扩展方法的最佳方法是什么?

javascript - 用 should.js 做 assert.fail() 最可读的方法是什么

c++ - 与 MFC 集成的报表生成器

java - 由于意外的内存不足错误,应用程序失败。

java - 如何实例化 JAXBElement<String> 对象?

java - 无法将 .war 应用程序部署到 GlassFish 3.1.2

java - 如果数组元素的值等于 4,如何将其更改为 5 并通知更改次数?

c# - 如何编写使用 HttpContext 的服务器端单元测试?

reporting - 邮件 API - MailChimp VS Amazon SES VS mailgun

java - Jasperreports多个子报表重叠