Java Code Examples for com.aventstack.extentreports.ExtentReports#flush()

The following examples show how to use com.aventstack.extentreports.ExtentReports#flush() . 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: 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 3
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 4
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 5
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 6
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 7
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 8
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 9
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 10
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 11
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);
}