Skip to content

Commit 2d0f528

Browse files
committed
Add Spark:config tests
1 parent 7214097 commit 2d0f528

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/test/java/com/aventstack/extentreports/reporter/SparkReporterConfigTest.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.aventstack.extentreports.reporter;
22

3+
import java.io.File;
4+
import java.io.IOException;
5+
36
import org.testng.Assert;
47
import org.testng.annotations.Test;
58

@@ -18,4 +21,41 @@ public void configTest() {
1821
Assert.assertEquals(spark.getConf().getTheme(), Theme.DARK);
1922
Assert.assertEquals(spark.getConf().getDocumentTitle(), "MyReport");
2023
}
24+
25+
@Test
26+
public void loadJSONConfigFileTest() throws IOException {
27+
ExtentSparkReporter spark = new ExtentSparkReporter("target/spark.html");
28+
spark.loadJSONConfig(new File("config/spark-config.json"));
29+
Assert.assertEquals(spark.getConf().getTheme(), Theme.STANDARD);
30+
Assert.assertEquals(spark.getConf().getDocumentTitle(), "ExtentReports");
31+
Assert.assertEquals(spark.getConf().getEncoding(), "utf-8");
32+
}
33+
34+
@Test
35+
public void loadJSONConfigStringTest() throws IOException {
36+
String json = "{ 'theme': 'DARK', 'documentTitle': 'Extent', 'encoding': 'utf-8' }";
37+
ExtentSparkReporter spark = new ExtentSparkReporter("target/spark.html");
38+
spark.loadJSONConfig(json);
39+
Assert.assertEquals(spark.getConf().getTheme(), Theme.DARK);
40+
Assert.assertEquals(spark.getConf().getDocumentTitle(), "Extent");
41+
Assert.assertEquals(spark.getConf().getEncoding(), "utf-8");
42+
}
43+
44+
@Test
45+
public void loadXMLConfigFileTest() throws IOException {
46+
ExtentSparkReporter spark = new ExtentSparkReporter("target/spark.html");
47+
spark.loadXMLConfig(new File("config/spark-config.xml"));
48+
Assert.assertEquals(spark.getConf().getReportName(), "Build 1");
49+
Assert.assertEquals(spark.getConf().getDocumentTitle(), "Extent Framework");
50+
Assert.assertEquals(spark.getConf().getEncoding(), "UTF-8");
51+
}
52+
53+
@Test
54+
public void loadXMLConfigPathTest() throws IOException {
55+
ExtentSparkReporter spark = new ExtentSparkReporter("target/spark.html");
56+
spark.loadXMLConfig("config/spark-config.xml");
57+
Assert.assertEquals(spark.getConf().getReportName(), "Build 1");
58+
Assert.assertEquals(spark.getConf().getDocumentTitle(), "Extent Framework");
59+
Assert.assertEquals(spark.getConf().getEncoding(), "UTF-8");
60+
}
2161
}

0 commit comments

Comments
 (0)