/
CombineReportSample.java
105 lines (79 loc) · 3.88 KB
/
CombineReportSample.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package tech.grasshopper.combiner;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
import tech.grasshopper.combiner.options.PojoOptions;
import tech.grasshopper.combiner.strategy.matching.MatchingScenarioTestStrategy.EarlierScenarioTestStrategy;
import tech.grasshopper.combiner.strategy.matching.MatchingScenarioTestStrategy.HighStatusScenarioTestStrategy;
import tech.grasshopper.combiner.strategy.matching.MatchingScenarioTestStrategy.LaterScenarioTestStrategy;
import tech.grasshopper.combiner.strategy.matching.MatchingScenarioTestStrategy.LowStatusScenarioTestStrategy;
public class CombineReportSample {
private PojoOptions pojoOption;
@Test
public void separateScenariosCombine() {
createOptionsAndExecute("separate scens");
}
@Test
public void sameScenarioOutlineSeparateScenariosCombine() {
createOptionsAndExecute("same sos separate scens");
}
@Test
public void sameScenarioEarlierStrategyCombine() {
createOptionsWithMatchingStrategyAndExecute("time", "early", EarlierScenarioTestStrategy.NAME);
}
@Test
public void sameScenarioLaterStrategyCombine() {
createOptionsWithMatchingStrategyAndExecute("time", "later", LaterScenarioTestStrategy.NAME);
}
@Test
public void sameScenarioHighStatusStrategyCombine() {
createOptionsWithMatchingStrategyAndExecute("status", "high status", HighStatusScenarioTestStrategy.NAME);
}
@Test
public void sameScenarioLowStatusStrategyCombine() {
createOptionsWithMatchingStrategyAndExecute("status", "low status", LowStatusScenarioTestStrategy.NAME);
}
@Test
public void multipleReportsCombine() {
String workingDir = "multiple";
List<String> reports = Arrays.asList(new String[] { "sample/combine/" + workingDir + "/ExtentJsonOne.json",
"sample/combine/" + workingDir + "/ExtentJsonTwo.json",
"sample/combine/" + workingDir + "/ExtentJsonThree.json",
"sample/combine/" + workingDir + "/ExtentJsonFour.json" });
pojoOption = PojoOptions.builder().jsonReportPaths(reports).mergedReportDirPath(createMergedDirPath(workingDir))
.configType("xml").build();
Combiner.main(pojoOption);
}
@Test
public void mediaReportsCombine() {
String workingDir = "media";
List<String> reports = Arrays.asList(new String[] { "sample/combine/" + workingDir + "/first/ExtentJson.json",
"sample/combine/" + workingDir + "/second/ExtentJson.json",
"sample/combine/" + workingDir + "/no media/ExtentJson.json" });
List<String> medias = Arrays.asList(new String[] { "sample/combine/" + workingDir + "/first",
"sample/combine/" + workingDir + "/second", "sample/combine/" + workingDir + "/no media" });
pojoOption = PojoOptions.builder().jsonReportPaths(reports).mergedReportDirPath(createMergedDirPath(workingDir))
.mediaPaths(medias).build();
Combiner.main(pojoOption);
}
private void createOptionsAndExecute(String workingDir) {
pojoOption = PojoOptions.builder().jsonReportPaths(createJsonReportList(workingDir))
.mergedReportDirPath(createMergedDirPath(workingDir)).configType("xml").build();
Combiner.main(pojoOption);
}
private List<String> createJsonReportList(String workingDir) {
return Arrays.asList(new String[] { "sample/combine/" + workingDir + "/ExtentJsonOne.json",
"sample/combine/" + workingDir + "/ExtentJsonTwo.json" });
}
private String createMergedDirPath(String workingDir) {
return "sample/combine/" + workingDir;
}
private void createOptionsWithMatchingStrategyAndExecute(String jsonReportDir, String workingDir, String strategy) {
workingDir = "matching/" + workingDir;
jsonReportDir = "matching/" + jsonReportDir;
pojoOption = PojoOptions.builder().matchingScenarioTestStrategy(strategy)
.jsonReportPaths(createJsonReportList(jsonReportDir))
.mergedReportDirPath(createMergedDirPath(workingDir)).configType("xml").build();
Combiner.main(pojoOption);
}
}