如何使用selenium web驱动程序生成测试报告

时间:2014-09-16 06:46:08

标签: selenium

我想知道除了selenium webdriver中的TestNG框架之外还有其他可用于生成测试报告的选项

2 个答案:

答案 0 :(得分:4)

您可以尝试ExtentReports:http://extentreports.com。一个例子:

public class Main {
public static void main(String[] args) {
    // start reporters
    ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter("extent.html");

    // create ExtentReports and attach reporter(s)
    ExtentReports extent = new ExtentReports();
    extent.attachReporter(htmlReporter);

    // creates a toggle for the given test, adds all log events under it    
    ExtentTest test = extent.createTest("MyFirstTest", "Sample description");

    // log(Status, details)
    test.log(Status.INFO, "This step shows usage of log(status, details)");

    // info(details)
    test.info("This step shows usage of info(details)");

    // log with snapshot
    test.fail("details", MediaEntityBuilder.createScreenCaptureFromPath("screenshot.png").build());

    // test with snapshot
    test.addScreenCaptureFromPath("screenshot.png");

    // calling flush writes everything to the log file
    extent.flush();
}
}

答案 1 :(得分:1)

尝试Allure报告框架

https://github.com/allure-framework

希望这有帮助