com.aventstack.extentreports.ExtentReports Java Examples

The following examples show how to use com.aventstack.extentreports.ExtentReports. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExtentReportsBuilder.java    From courgette-jvm with MIT License 7 votes vote down vote up
public void buildReport() {
    final ExtentSparkReporter extentSparkReporter = new ExtentSparkReporter(extentReportsProperties.getReportFilename());

    if (extentReportsProperties.getXMLConfigFile() != null) {
        extentSparkReporter.loadXMLConfig(extentReportsProperties.getXMLConfigFile(), true);
    }

    final ExtentReports extentReports = new ExtentReports();
    extentReports.setReportUsesManualConfiguration(true);
    extentReports.attachReporter(extentSparkReporter);

    getDistinctFeatureUris().forEach(featureUri -> {
        List<Feature> features = featureList.stream().filter(f -> f.getUri().equals(featureUri)).collect(Collectors.toList());
        addFeatures(extentReports, features);
    });
    extentReports.flush();
}
 
Example #2
Source File: ExtentTestNGIReporterListenerOld.java    From Java-API-Test-Examples with Apache License 2.0 6 votes vote down vote up
private void init() {
    //文件夹不存在的话进行创建
    File reportDir= new File(OUTPUT_FOLDER);
    if(!reportDir.exists()&& !reportDir .isDirectory()){
        reportDir.mkdir();
    }
    ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(OUTPUT_FOLDER + FILE_NAME);
    // 设置静态文件的DNS
    //解决cdn.rawqit.com css访问不了的情况
    htmlReporter.config().setResourceCDN(ResourceCDN.EXTENTREPORTS);
    htmlReporter.config().setDocumentTitle("api自动化测试报告");
    htmlReporter.config().setReportName("api自动化测试报告");
    htmlReporter.config().setChartVisibilityOnOpen(true);
    htmlReporter.config().setTestViewChartLocation(ChartLocation.TOP);
    htmlReporter.config().setTheme(Theme.STANDARD);
    htmlReporter.config().setCSS(".node.level-1  ul{ display:none;} .node.level-1.active ul{display:block;}");
    extent = new ExtentReports();
    extent.attachReporter(htmlReporter);
    extent.setReportUsesManualConfiguration(true);
}
 
Example #3
Source File: ExtentReportsBuilder.java    From courgette-jvm with MIT License 6 votes vote down vote up
private void addFeatures(ExtentReports extentReports, List<Feature> features) {
    final ExtentTest featureNode = createBddTest(extentReports, features.get(0).getName());

    features.forEach(feature -> {
        if (feature.getScenarios().size() > 1) {
            addFeatureStartAndEndTime(featureNode, feature);
        }

        for (Scenario scenario : feature.getScenarios()) {
            if (scenario.getKeyword().startsWith("Scenario")) {
                addScenario(featureNode, scenario);
                addScenarioStartAndEndTime(featureNode, scenario);
            }
        }
    });
}
 
Example #4
Source File: GherkinKeywordTest.java    From extentreports-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testGermanGherkinKeywords() throws ClassNotFoundException, UnsupportedEncodingException {
    ExtentReports extent = extent();
    extent.setGherkinDialect("de");
    
    ExtentTest feature = extent.createTest(new GherkinKeyword("Funktionalität"), "Refund item VM");
    ExtentTest scenario = feature.createNode(new GherkinKeyword("Szenario"), "Jeff returns a faulty microwave");
    ExtentTest given = scenario.createNode(new GherkinKeyword("Angenommen"), "Jeff has bought a microwave for $100").skip("skip");
    ExtentTest and = scenario.createNode(new GherkinKeyword("Und"), "he has a receipt").pass("pass");
    ExtentTest when = scenario.createNode(new GherkinKeyword("Wenn"), "he returns the microwave").pass("pass");
    ExtentTest then = scenario.createNode(new GherkinKeyword("Dann"), "Jeff should be refunded $100").skip("skip");
    
    Assert.assertEquals(feature.getModel().getBddType(), Feature.class);
    Assert.assertEquals(scenario.getModel().getBddType(), Scenario.class);
    Assert.assertEquals(given.getModel().getBddType(), Given.class);
    Assert.assertEquals(and.getModel().getBddType(), And.class);
    Assert.assertEquals(when.getModel().getBddType(), When.class);
    Assert.assertEquals(then.getModel().getBddType(), Then.class);
}
 
Example #5
Source File: GherkinKeywordTest.java    From extentreports-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testEnglishGherkinKeywords() throws ClassNotFoundException, UnsupportedEncodingException {
    ExtentReports extent = extent();
    extent.setGherkinDialect("en");
    
    ExtentTest feature = extent.createTest(new GherkinKeyword("Feature"), "Refund item VM");
    ExtentTest scenario = feature.createNode(new GherkinKeyword("Scenario"), "Jeff returns a faulty microwave");
    ExtentTest given = scenario.createNode(new GherkinKeyword("Given"), "Jeff has bought a microwave for $100").skip("skip");
    ExtentTest and = scenario.createNode(new GherkinKeyword("And"), "he has a receipt").pass("pass");
    ExtentTest when = scenario.createNode(new GherkinKeyword("When"), "he returns the microwave").pass("pass");
    ExtentTest then = scenario.createNode(new GherkinKeyword("Then"), "Jeff should be refunded $100").skip("skip");
    
    Assert.assertEquals(feature.getModel().getBddType(), Feature.class);
    Assert.assertEquals(scenario.getModel().getBddType(), Scenario.class);
    Assert.assertEquals(given.getModel().getBddType(), Given.class);
    Assert.assertEquals(and.getModel().getBddType(), And.class);
    Assert.assertEquals(when.getModel().getBddType(), When.class);
    Assert.assertEquals(then.getModel().getBddType(), Then.class);
}
 
Example #6
Source File: SparkReporterTest.java    From extentreports-java with Apache License 2.0 6 votes vote down vote up
@Test
public void statusFilterableNode() {
    ExtentReports extent = new ExtentReports();
    String path = path();
    ExtentSparkReporter spark = new ExtentSparkReporter(path)
            .filter()
            .statusFilter()
            .as(new Status[]{Status.FAIL})
            .apply();
    extent.attachReporter(spark);
    extent.createTest(PARENT).pass("Pass");
    extent.createTest(CHILD).pass("Pass")
            .createNode(GRANDCHILD).fail("Fail");
    extent.flush();
    assertFileExists(path);
    Assert.assertEquals(spark.getReport().getTestList().size(), 1);
    Assert.assertEquals(spark.getReport().getTestList().get(0).getName(), CHILD);
    Assert.assertEquals(spark.getReport().getTestList().get(0).getChildren().size(), 1);
    Assert.assertEquals(spark.getReport().getTestList().get(0).getChildren().get(0).getName(), GRANDCHILD);
}
 
Example #7
Source File: SparkReporterTest.java    From extentreports-java with Apache License 2.0 6 votes vote down vote up
@Test
public void statusFilterable() {
    ExtentReports extent = new ExtentReports();
    String path = path();
    ExtentSparkReporter spark = new ExtentSparkReporter(path)
            .filter()
            .statusFilter()
            .as(new Status[]{Status.FAIL})
            .apply();
    extent.attachReporter(spark);
    extent.createTest(PARENT).pass("Pass");
    extent.createTest(CHILD).fail("Fail");
    extent.flush();
    assertFileExists(path);
    Assert.assertEquals(spark.getReport().getTestList().size(), 1);
    Assert.assertEquals(spark.getReport().getTestList().get(0).getName(), CHILD);
}
 
Example #8
Source File: SparkReporterTest.java    From extentreports-java with Apache License 2.0 6 votes vote down vote up
@Test
public void reportContainsTestsAndNodesDevices() {
    ExtentReports extent = new ExtentReports();
    String path = path();
    ExtentSparkReporter spark = new ExtentSparkReporter(path);
    extent.attachReporter(spark);
    extent.createTest(PARENT).assignDevice("Tag1")
            .createNode(CHILD).assignDevice("Tag2")
            .createNode(GRANDCHILD).assignDevice("Tag3")
            .pass("Pass");
    extent.flush();
    assertFileExists(path);
    com.aventstack.extentreports.model.Test t = spark.getReport().getTestList().get(0);
    Assert.assertTrue(t.getDeviceSet().stream().anyMatch(x -> x.getName().equals("Tag1")));
    Assert.assertTrue(t.getChildren().get(0).getDeviceSet().stream().anyMatch(x -> x.getName().equals("Tag2")));
    Assert.assertTrue(t.getChildren().get(0).getChildren().get(0).getDeviceSet().stream()
            .anyMatch(x -> x.getName().equals("Tag3")));
}
 
Example #9
Source File: SparkReporterTest.java    From extentreports-java with Apache License 2.0 6 votes vote down vote up
@Test
public void reportContainsTestsAndNodesUsers() {
    ExtentReports extent = new ExtentReports();
    String path = path();
    ExtentSparkReporter spark = new ExtentSparkReporter(path);
    extent.attachReporter(spark);
    extent.createTest(PARENT).assignAuthor("Tag1")
            .createNode(CHILD).assignAuthor("Tag2")
            .createNode(GRANDCHILD).assignAuthor("Tag3")
            .pass("Pass");
    extent.flush();
    assertFileExists(path);
    com.aventstack.extentreports.model.Test t = spark.getReport().getTestList().get(0);
    Assert.assertTrue(t.getAuthorSet().stream().anyMatch(x -> x.getName().equals("Tag1")));
    Assert.assertTrue(t.getChildren().get(0).getAuthorSet().stream().anyMatch(x -> x.getName().equals("Tag2")));
    Assert.assertTrue(t.getChildren().get(0).getChildren().get(0).getAuthorSet().stream()
            .anyMatch(x -> x.getName().equals("Tag3")));
}
 
Example #10
Source File: SparkReporterTest.java    From extentreports-java with Apache License 2.0 6 votes vote down vote up
@Test
public void reportContainsTestsAndNodesTags() {
    ExtentReports extent = new ExtentReports();
    String path = path();
    ExtentSparkReporter spark = new ExtentSparkReporter(path);
    extent.attachReporter(spark);
    extent.createTest(PARENT).assignCategory("Tag1")
            .createNode(CHILD).assignCategory("Tag2")
            .createNode(GRANDCHILD).assignCategory("Tag3")
            .pass("Pass");
    extent.flush();
    assertFileExists(path);
    com.aventstack.extentreports.model.Test t = spark.getReport().getTestList().get(0);
    Assert.assertTrue(t.getCategorySet().stream().anyMatch(x -> x.getName().equals("Tag1")));
    Assert.assertTrue(t.getChildren().get(0).getCategorySet().stream().anyMatch(x -> x.getName().equals("Tag2")));
    Assert.assertTrue(t.getChildren().get(0).getChildren().get(0).getCategorySet().stream()
            .anyMatch(x -> x.getName().equals("Tag3")));
}
 
Example #11
Source File: SparkReporterTest.java    From extentreports-java with Apache License 2.0 6 votes vote down vote up
@Test
public void reportContainsTestsAndNodes() {
    ExtentReports extent = new ExtentReports();
    String path = path();
    ExtentSparkReporter spark = new ExtentSparkReporter(path);
    extent.attachReporter(spark);
    extent.createTest(PARENT)
            .createNode(CHILD)
            .createNode(GRANDCHILD)
            .pass("Pass");
    extent.flush();
    assertFileExists(path);
    Assert.assertEquals(spark.getReport().getTestList().size(), 1);
    Assert.assertEquals(spark.getReport().getTestList().get(0).getName(), PARENT);
    Assert.assertEquals(spark.getReport().getTestList().get(0).getChildren().size(), 1);
    Assert.assertEquals(spark.getReport().getTestList().get(0).getChildren().get(0).getName(), CHILD);
    Assert.assertEquals(spark.getReport().getTestList().get(0).getChildren().get(0).getChildren().size(), 1);
    Assert.assertEquals(spark.getReport().getTestList().get(0).getChildren().get(0).getChildren().get(0).getName(),
            GRANDCHILD);
}
 
Example #12
Source File: ReportEntityTest.java    From extentreports-java with Apache License 2.0 6 votes vote down vote up
@org.testng.annotations.Test
public void exceptionContext() {
    String msg = "An exception has occurred.";
    RuntimeException ex = new RuntimeException(msg);
    ExtentReports extent = extent();
    ExtentTest test = extent.createTest("Test");
    NamedAttributeContextManager<ExceptionInfo> context = extent.getReport().getExceptionInfoCtx();
    Assert.assertFalse(context.hasItems());
    test.fail(ex);
    test.assignDevice("x");
    Assert.assertTrue(context.hasItems());
    Assert.assertTrue(
            context.getSet().stream().anyMatch(x -> x.getAttr().getName().equals("java.lang.RuntimeException")));
    Assert.assertTrue(context.getSet().stream().anyMatch(x -> x.getTestList().size() == 1));
    Assert.assertTrue(context.getSet().stream()
            .flatMap(x -> x.getTestList().stream())
            .anyMatch(x -> x.getName().equals("Test")));
}
 
Example #13
Source File: SparkReporterTest.java    From extentreports-java with Apache License 2.0 5 votes vote down vote up
@Test
public void createsReportWithNoTestsInitFile() {
    ExtentReports extent = new ExtentReports();
    String path = path();
    ExtentSparkReporter spark = new ExtentSparkReporter(new File(path));
    extent.attachReporter(spark);
    extent.flush();
    assertFileExists(path);
}
 
Example #14
Source File: ExtentTestNGIReporterListenerOld.java    From Java-API-Test-Examples with Apache License 2.0 5 votes vote down vote up
private void init() {
        //文件夹不存在的话进行创建
        File reportDir= new File(OUTPUT_FOLDER);
        if(!reportDir.exists()&& !reportDir .isDirectory()){
            reportDir.mkdir();
        }
        ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(OUTPUT_FOLDER + FILE_NAME);
        // 设置静态文件的DNS
        //解决cdn.rawqit.com css访问不了的情况
//        htmlReporter.config().setResourceCDN(ResourceCDN.EXTENTREPORTS);
        htmlReporter.config().setDocumentTitle("api自动化测试报告");
        htmlReporter.config().setReportName("api自动化测试报告");
//        htmlReporter.config().setChartVisibilityOnOpen(true);
//        htmlReporter.config().setTestViewChartLocation(ChartLocation.TOP);
        htmlReporter.config().setTheme(Theme.STANDARD);
        htmlReporter.config().setCSS(".node.level-1  ul{ display:none;} .node.level-1.active ul{display:block;}");

        //  创建一个KlovReporter对象
        ExtentKlovReporter klov = new ExtentKlovReporter();
        //  定义MongoDB连接
        klov.initMongoDbConnection("localhost", 27017);
        //  设置klov服务器URL
        klov.initKlovServerConnection("http://localhost");
        //  为我们的测试项目提供项目名称
        klov.setProjectName("zuozewei-test");
        klov.setReportName("1.0");

        //  邮件报告名emailable-report.html
        File emailReportFile = new File(reportDir, "emailable-report.html");
        EmailReporter emailReporter = new EmailReporter(emailReportFile);

        extent = new ExtentReports();
        extent.attachReporter(htmlReporter,klov,emailReporter);
        extent.setReportUsesManualConfiguration(true);
    }
 
Example #15
Source File: ExtentTestNGIReporterListenerOld.java    From Java-API-Test-Examples with Apache License 2.0 5 votes vote down vote up
private void init() {
        //文件夹不存在的话进行创建
        File reportDir= new File(OUTPUT_FOLDER);
        if(!reportDir.exists()&& !reportDir .isDirectory()){
            reportDir.mkdir();
        }
        ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(OUTPUT_FOLDER + FILE_NAME);
        // 设置静态文件的DNS
        //解决cdn.rawqit.com css访问不了的情况
//        htmlReporter.config().setResourceCDN(ResourceCDN.EXTENTREPORTS);
        htmlReporter.config().setDocumentTitle("api自动化测试报告");
        htmlReporter.config().setReportName("api自动化测试报告");
//        htmlReporter.config().setChartVisibilityOnOpen(true);
//        htmlReporter.config().setTestViewChartLocation(ChartLocation.TOP);
        htmlReporter.config().setTheme(Theme.STANDARD);
        htmlReporter.config().setCSS(".node.level-1  ul{ display:none;} .node.level-1.active ul{display:block;}");

        //  创建一个KlovReporter对象
        ExtentKlovReporter klov = new ExtentKlovReporter();
        //  定义MongoDB连接
        klov.initMongoDbConnection("localhost", 27017);
        //  设置klov服务器URL
        klov.initKlovServerConnection("http://localhost");
        //  为我们的测试项目提供项目名称
        klov.setProjectName("zuozewei-test");
        klov.setReportName("1.0");

        //  邮件报告名emailable-report.html
        File emailReportFile = new File(reportDir, "emailable-report.html");
        EmailReporter emailReporter = new EmailReporter(emailReportFile);

        extent = new ExtentReports();
        extent.attachReporter(htmlReporter,klov,emailReporter);
        extent.setReportUsesManualConfiguration(true);
    }
 
Example #16
Source File: ExtentTestNGIReporterListener.java    From Selenium-Framework-Design-in-Data-Driven-Testing with MIT License 5 votes vote down vote up
/**
 * init method to customize report
 *
 * @param suite
 */
private void init(ISuite suite) {
    File directory = new File(Global_VARS.REPORT_PATH);

    if ( !directory.exists() ) {
        directory.mkdirs();
    }

    ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(Global_VARS.REPORT_PATH + suite.getName() + ".html");

    // report attributes
    htmlReporter.config().setDocumentTitle(docTitle);
    htmlReporter.config().setReportName(suite.getName().replace("_", " "));
    htmlReporter.config().setChartVisibilityOnOpen(false);
    htmlReporter.config().setTheme(Theme.STANDARD);
    htmlReporter.config().setEncoding("UTF-8");
    htmlReporter.config().setProtocol(Protocol.HTTPS);
    htmlReporter.config().setTimeStampFormat("MMM-dd-yyyy HH:mm:ss a");
    htmlReporter.loadXMLConfig(new File(Global_VARS.REPORT_CONFIG_FILE));

    extent = new ExtentReports();

    // report system info
    extent.setSystemInfo("Browser", Global_VARS.DEF_BROWSER);
    extent.setSystemInfo("Environment", Global_VARS.DEF_ENVIRONMENT);
    extent.setSystemInfo("Platform", Global_VARS.DEF_PLATFORM);
    extent.setSystemInfo("OS Version", System.getProperty("os.version"));
    extent.setSystemInfo("Java Version", System.getProperty("java.version"));
    extent.setSystemInfo("Selenium Version", seleniumRev);

    extent.attachReporter(htmlReporter);
    extent.setReportUsesManualConfiguration(true);
}
 
Example #17
Source File: ExtentSparkReporterConfig.java    From extentreports-java with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the HTML report, saving all resources (css, js, fonts) in the
 * same location, so the report can be viewed without an internet connection
 * 
 * @param offlineMode
 *            Setting to enable an offline accessible report
 */
public void enableOfflineMode(Boolean offlineMode) {
    this.offlineMode = offlineMode;
    if (offlineMode && reporter != null) {
        File f = Offline.getTargetDirectory(((ExtentSparkReporter) reporter).getFile());
        String resPackage = ExtentReports.class.getPackage().getName().replace(".", SEP);
        resPackage += SEP + "offline" + SEP;
        String[] resx = Offline.combineAll();
        ResourceHelper.saveOfflineResources(resPackage, resx, f.getAbsolutePath());
    }
}
 
Example #18
Source File: SparkReporterTest.java    From extentreports-java with Apache License 2.0 5 votes vote down vote up
@Test
public void createsReportWithNoTestsInitPath() {
    ExtentReports extent = new ExtentReports();
    String path = path();
    ExtentSparkReporter spark = new ExtentSparkReporter(path);
    extent.attachReporter(spark);
    extent.flush();
    assertFileExists(path);
}
 
Example #19
Source File: ReportEntityObserverTest.java    From extentreports-java with Apache License 2.0 5 votes vote down vote up
@Test
public void disposableNonNull() {
    ExtentReports extent = new ExtentReports();
    Assert.assertNull(disp);
    Assert.assertNull(entity);
    extent.attachReporter(new TestReporter());
    Assert.assertNotNull(disp);
    Assert.assertNull(entity);
    extent.flush();
    Assert.assertNotNull(disp);
    Assert.assertNotNull(entity);
}
 
Example #20
Source File: SparkReporterTest.java    From extentreports-java with Apache License 2.0 5 votes vote down vote up
@Test
public void sparkOffline() {
    ExtentReports extent = new ExtentReports();
    String path = path();
    ExtentSparkReporter spark = new ExtentSparkReporter(path);
    spark.config().enableOfflineMode(true);
    extent.attachReporter(spark);
    extent.createTest(PARENT).pass("Pass");
    extent.flush();
    assertFileExists(path);
    Assert.assertTrue(new File(FILE_PATH + "spark/" + SCRIPTS).exists());
    Assert.assertTrue(new File(FILE_PATH + "spark/" + STYLESHEET).exists());
}
 
Example #21
Source File: ReportEntityTest.java    From extentreports-java with Apache License 2.0 5 votes vote down vote up
@org.testng.annotations.Test
public void authorCtx() {
    ExtentReports extent = extent();
    ExtentTest test = extent.createTest("Test");
    NamedAttributeContextManager<Author> context = extent.getReport().getAuthorCtx();
    Assert.assertFalse(context.hasItems());
    test.assignAuthor("x");
    Assert.assertTrue(context.hasItems());
    Assert.assertTrue(context.getSet().stream().anyMatch(x -> x.getAttr().getName().equals("x")));
    Assert.assertTrue(context.getSet().stream().anyMatch(x -> x.getTestList().size() == 1));
    Assert.assertTrue(context.getSet().stream()
            .flatMap(x -> x.getTestList().stream())
            .anyMatch(x -> x.getName().equals("Test")));
}
 
Example #22
Source File: ReportEntityTest.java    From extentreports-java with Apache License 2.0 5 votes vote down vote up
@org.testng.annotations.Test
public void categoryCtx() {
    ExtentReports extent = extent();
    ExtentTest test = extent.createTest("Test");
    NamedAttributeContextManager<Category> context = extent.getReport().getCategoryCtx();
    Assert.assertFalse(context.hasItems());
    test.assignCategory("x");
    Assert.assertTrue(context.hasItems());
    Assert.assertTrue(context.getSet().stream().anyMatch(x -> x.getAttr().getName().equals("x")));
    Assert.assertTrue(context.getSet().stream().anyMatch(x -> x.getTestList().size() == 1));
    Assert.assertTrue(context.getSet().stream()
            .flatMap(x -> x.getTestList().stream())
            .anyMatch(x -> x.getName().equals("Test")));
}
 
Example #23
Source File: ReportEntityTest.java    From extentreports-java with Apache License 2.0 5 votes vote down vote up
@org.testng.annotations.Test
public void deviceCtx() {
    ExtentReports extent = extent();
    ExtentTest test = extent.createTest("Test");
    NamedAttributeContextManager<Device> context = extent.getReport().getDeviceCtx();
    Assert.assertFalse(context.hasItems());
    test.assignDevice("x");
    Assert.assertTrue(context.hasItems());
    Assert.assertTrue(context.getSet().stream().anyMatch(x -> x.getAttr().getName().equals("x")));
    Assert.assertTrue(context.getSet().stream().anyMatch(x -> x.getTestList().size() == 1));
    Assert.assertTrue(context.getSet().stream()
            .flatMap(x -> x.getTestList().stream())
            .anyMatch(x -> x.getName().equals("Test")));
}
 
Example #24
Source File: ReportEntityTest.java    From extentreports-java with Apache License 2.0 5 votes vote down vote up
@org.testng.annotations.Test
public void testRunnerLogs() {
    String[] s = new String[]{"Log 1", "Log 2", "Log 3"};
    ExtentReports extent = extent();
    List<String> logs = extent.getReport().getLogs();
    Assert.assertTrue(logs.isEmpty());
    Arrays.stream(s).forEach(x -> extent.addTestRunnerOutput(x));
    Assert.assertFalse(logs.isEmpty());
    Arrays.stream(s).forEach(x -> Assert.assertTrue(logs.contains(x)));
}
 
Example #25
Source File: ZeroCodeReportGeneratorImpl.java    From zerocode with Apache License 2.0 4 votes vote down vote up
@Override
public void generateExtentReport() {

    if (interactiveHtmlReportDisabled) {
        return;
    }

    ExtentReports extentReports = ExtentReportsFactory.createReportTheme(TARGET_FILE_NAME);

    linkToSpikeChartIfEnabled();

    treeReports.forEach(thisReport -> {

        thisReport.getResults().forEach(thisScenario -> {
            ExtentTest test = extentReports.createTest(thisScenario.getScenarioName());
            test.assignCategory(DEFAULT_REGRESSION_CATEGORY);

            test.assignAuthor(optionalAuthor(thisScenario.getScenarioName()));
            List<ZeroCodeReportStep> thisScenarioUniqueSteps = getUniqueSteps(thisScenario.getSteps());
            thisScenarioUniqueSteps.forEach(thisStep -> {
                test.getModel().setStartTime(utilDateOf(thisStep.getRequestTimeStamp()));
                test.getModel().setEndTime(utilDateOf(thisStep.getResponseTimeStamp()));

                final Status testStatus = thisStep.getResult().equals(RESULT_PASS) ? Status.PASS : Status.FAIL;

                ExtentTest step = test.createNode(thisStep.getName(), TEST_STEP_CORRELATION_ID + " " + thisStep.getCorrelationId());

                if (testStatus.equals(Status.PASS)) {
                    step.pass(thisStep.getResult());
                } else {
                    step.info(MarkupHelper.createCodeBlock(thisStep.getOperation() + "\t" + thisStep.getUrl()));
                    step.info(MarkupHelper.createCodeBlock(thisStep.getRequest(), CodeLanguage.JSON));
                    step.info(MarkupHelper.createCodeBlock(thisStep.getResponse(), CodeLanguage.JSON));
                    step.fail(MarkupHelper.createCodeBlock("Reason:\n" + thisStep.getAssertions()));
                }
                extentReports.flush();
            });

        });

    });
}
 
Example #26
Source File: ExtentReportsBuilder.java    From courgette-jvm with MIT License 4 votes vote down vote up
private ExtentTest createBddTest(ExtentReports extentReports, String featureName) {
    ExtentTest featureNode = extentReports.createTest(featureName);
    featureNode.getModel().setBddType(com.aventstack.extentreports.gherkin.model.Feature.class);
    return featureNode;
}
 
Example #27
Source File: RawEntityConverter.java    From extentreports-java with Apache License 2.0 4 votes vote down vote up
public RawEntityConverter(ExtentReports extent) {
    this.extent = extent;
}
 
Example #28
Source File: ExtentService.java    From extentreports-cucumber4-adapter with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unused")
private ExtentReports readResolve() {
    return ExtentReportsLoader.INSTANCE;
}
 
Example #29
Source File: ExtentService.java    From extentreports-cucumber4-adapter with Apache License 2.0 4 votes vote down vote up
public static synchronized ExtentReports getInstance() {
    return ExtentReportsLoader.INSTANCE;
}
 
Example #30
Source File: ExtentService.java    From extentreports-testng-adapter with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unused")
private ExtentReports readResolve() {
    return ExtentReportsLoader.INSTANCE;
}