微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Java:范围报告仅显示最后一次测试

如何解决Java:范围报告仅显示最后一次测试

这是我的范围报告class

public class ExtentReport {

    public static ExtentHtmlReporter extentHtmlReporter;
    public static ExtentReports extentReports;
    public static ExtentTest extentTest;

    public static void init() throws Exception {
        extentHtmlReporter = new ExtentHtmlReporter(getLocalLocation());
        extentReports = new ExtentReports();
        extentReports.attachReporter(extentHtmlReporter);
    }

    private static String getLocalLocation() throws Exception {
        String location = "";
        switch (OsCheck.getoperatingSystemType()) {
            case Windows:
                location = ".\\reports\\report.html";
                break;

            case Mac:
                location = "./reports/report.html";
                break;

            case Linux:
                location = "./reports/report.html";
                break;
        }

        return location;
    }
}

测试class

public class TestClass {
    @Before
    public void setup() throws Exception {
        ExtentReport.init();
        ExtentReport.extentTest = ExtentReport.extentReports.createTest("Setup");
    }

    @After
    public void cleanup() {
        ExtentReport.extentTest = ExtentReport.extentReports.createTest("Cleanup","Clean system");
        ExtentReport.extentReports.flush();
    }

    @Test
    public void test1(){
        ExtentReport.extentTest = ExtentReport.extentReports.createTest("test1");
        Assert.assertEquals(1,1);
    }

    @Test
    public void test2(){
        ExtentReport.extentTest = ExtentReport.extentReports.createTest("test2");
        Assert.assertEquals(1,1);
    }

    @Test
    public void test3(){
        ExtentReport.extentTest = ExtentReport.extentReports.createTest("test3");
        Assert.assertEquals(1,1);
    }
}

在我的报告中,我只能看到上次运行的测试。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。