8
8
import com .aventstack .extentreports .gherkin .GherkinDialectManager ;
9
9
import com .aventstack .extentreports .gherkin .model .Feature ;
10
10
import com .aventstack .extentreports .model .Test ;
11
+ import org .testng .annotations .BeforeMethod ;
11
12
12
13
public class ExtentReportsTest {
14
+
13
15
private static final String TEST_NAME = "TEST" ;
16
+ private ExtentReports extent ;
14
17
15
- private ExtentReports extent () {
16
- return new ExtentReports ();
18
+ @ BeforeMethod
19
+ public void beforeMethod () throws UnsupportedEncodingException {
20
+ extent = new ExtentReports ();
21
+ extent .setGherkinDialect ("en" );
17
22
}
18
23
19
24
@ org .testng .annotations .Test
20
25
public void createTestOverloadTypeNameDesc () {
21
- ExtentTest test = extent () .createTest (Feature .class , TEST_NAME , "Description" );
26
+ ExtentTest test = extent .createTest (Feature .class , TEST_NAME , "Description" );
22
27
Test model = test .getModel ();
23
28
Assert .assertTrue (model .isBDD ());
24
29
Assert .assertEquals (model .getName (), TEST_NAME );
@@ -29,7 +34,7 @@ public void createTestOverloadTypeNameDesc() {
29
34
30
35
@ org .testng .annotations .Test
31
36
public void createTestOverloadTypeName () {
32
- ExtentTest test = extent () .createTest (Feature .class , TEST_NAME );
37
+ ExtentTest test = extent .createTest (Feature .class , TEST_NAME );
33
38
Test model = test .getModel ();
34
39
Assert .assertTrue (model .isBDD ());
35
40
Assert .assertEquals (model .getName (), TEST_NAME );
@@ -40,7 +45,7 @@ public void createTestOverloadTypeName() {
40
45
41
46
@ org .testng .annotations .Test
42
47
public void createTestOverloadKeywordNameDesc () throws ClassNotFoundException {
43
- ExtentTest test = extent () .createTest (new GherkinKeyword ("Feature" ), TEST_NAME , "Description" );
48
+ ExtentTest test = extent .createTest (new GherkinKeyword ("Feature" ), TEST_NAME , "Description" );
44
49
Test model = test .getModel ();
45
50
Assert .assertTrue (model .isBDD ());
46
51
Assert .assertEquals (model .getName (), TEST_NAME );
@@ -51,7 +56,7 @@ public void createTestOverloadKeywordNameDesc() throws ClassNotFoundException {
51
56
52
57
@ org .testng .annotations .Test
53
58
public void createTestOverloadKeywordName () throws ClassNotFoundException {
54
- ExtentTest test = extent () .createTest (new GherkinKeyword ("Feature" ), TEST_NAME );
59
+ ExtentTest test = extent .createTest (new GherkinKeyword ("Feature" ), TEST_NAME );
55
60
Test model = test .getModel ();
56
61
Assert .assertTrue (model .isBDD ());
57
62
Assert .assertEquals (model .getName (), TEST_NAME );
@@ -62,7 +67,7 @@ public void createTestOverloadKeywordName() throws ClassNotFoundException {
62
67
63
68
@ org .testng .annotations .Test
64
69
public void createTestOverloadNameDesc () {
65
- ExtentTest test = extent () .createTest (TEST_NAME , "Description" );
70
+ ExtentTest test = extent .createTest (TEST_NAME , "Description" );
66
71
Test model = test .getModel ();
67
72
Assert .assertFalse (model .isBDD ());
68
73
Assert .assertEquals (model .getName (), TEST_NAME );
@@ -73,7 +78,7 @@ public void createTestOverloadNameDesc() {
73
78
74
79
@ org .testng .annotations .Test
75
80
public void createTestOverloadName () {
76
- ExtentTest test = extent () .createTest (TEST_NAME );
81
+ ExtentTest test = extent .createTest (TEST_NAME );
77
82
Test model = test .getModel ();
78
83
Assert .assertFalse (model .isBDD ());
79
84
Assert .assertEquals (model .getName (), TEST_NAME );
@@ -84,15 +89,13 @@ public void createTestOverloadName() {
84
89
85
90
@ org .testng .annotations .Test
86
91
public void gherkinDialect () throws UnsupportedEncodingException {
87
- ExtentReports extent = extent ();
88
92
extent .setGherkinDialect ("de" );
89
93
Assert .assertEquals (GherkinDialectManager .getLanguage (), "de" );
90
94
}
91
95
92
96
@ org .testng .annotations .Test
93
97
public void addTestRunnerOutputSingle () {
94
98
String [] logs = new String []{"Log1" , "Log2" };
95
- ExtentReports extent = extent ();
96
99
Arrays .stream (logs ).forEach (extent ::addTestRunnerOutput );
97
100
Assert .assertEquals (extent .getReport ().getLogs ().size (), 2 );
98
101
Arrays .stream (logs ).forEach (x -> Assert .assertTrue (extent .getReport ().getLogs ().contains (x )));
@@ -101,7 +104,6 @@ public void addTestRunnerOutputSingle() {
101
104
@ org .testng .annotations .Test
102
105
public void addTestRunnerOutputList () {
103
106
String [] logs = new String []{"Log1" , "Log2" };
104
- ExtentReports extent = extent ();
105
107
extent .addTestRunnerOutput (Arrays .asList (logs ));
106
108
Assert .assertEquals (extent .getReport ().getLogs ().size (), 2 );
107
109
Arrays .stream (logs ).forEach (x -> Assert .assertTrue (extent .getReport ().getLogs ().contains (x )));
0 commit comments