1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugin.surefire.extensions.junit5;
20
21 import org.apache.maven.plugin.surefire.extensions.DefaultStatelessReportMojoConfiguration;
22 import org.apache.maven.plugin.surefire.extensions.SurefireStatelessReporter;
23 import org.apache.maven.plugin.surefire.report.StatelessXmlReporter;
24 import org.apache.maven.plugin.surefire.report.TestSetStats;
25 import org.apache.maven.plugin.surefire.report.WrappedReportEntry;
26 import org.apache.maven.surefire.extensions.StatelessReportEventListener;
27
28
29
30
31
32
33
34
35 public class JUnit5Xml30StatelessReporter extends SurefireStatelessReporter {
36
37
38
39
40
41 private boolean usePhrasedFileName;
42
43
44
45
46
47
48 private boolean usePhrasedTestSuiteClassName;
49
50
51
52
53
54
55 private boolean usePhrasedTestCaseClassName;
56
57
58
59
60
61
62 private boolean usePhrasedTestCaseMethodName;
63
64 public boolean getUsePhrasedFileName() {
65 return usePhrasedFileName;
66 }
67
68 public void setUsePhrasedFileName(boolean usePhrasedFileName) {
69 this.usePhrasedFileName = usePhrasedFileName;
70 }
71
72 public boolean getUsePhrasedTestSuiteClassName() {
73 return usePhrasedTestSuiteClassName;
74 }
75
76 public void setUsePhrasedTestSuiteClassName(boolean usePhrasedTestSuiteClassName) {
77 this.usePhrasedTestSuiteClassName = usePhrasedTestSuiteClassName;
78 }
79
80 public boolean getUsePhrasedTestCaseClassName() {
81 return usePhrasedTestCaseClassName;
82 }
83
84 public void setUsePhrasedTestCaseClassName(boolean usePhrasedTestCaseClassName) {
85 this.usePhrasedTestCaseClassName = usePhrasedTestCaseClassName;
86 }
87
88 public boolean getUsePhrasedTestCaseMethodName() {
89 return usePhrasedTestCaseMethodName;
90 }
91
92 public void setUsePhrasedTestCaseMethodName(boolean usePhrasedTestCaseMethodName) {
93 this.usePhrasedTestCaseMethodName = usePhrasedTestCaseMethodName;
94 }
95
96 @Override
97 public StatelessReportEventListener<WrappedReportEntry, TestSetStats> createListener(
98 DefaultStatelessReportMojoConfiguration configuration) {
99 return new StatelessXmlReporter(
100 configuration.getReportsDirectory(),
101 configuration.getReportNameSuffix(),
102 configuration.isTrimStackTrace(),
103 configuration.getRerunFailingTestsCount(),
104 configuration.getTestClassMethodRunHistory(),
105 configuration.getXsdSchemaLocation(),
106 getVersion(),
107 getUsePhrasedFileName(),
108 getUsePhrasedTestSuiteClassName(),
109 getUsePhrasedTestCaseClassName(),
110 getUsePhrasedTestCaseMethodName(),
111 configuration.isEnableOutErrElements(),
112 configuration.isEnablePropertiesElement());
113 }
114
115 @Override
116 public Object clone(ClassLoader target) {
117 try {
118 Object clone = super.clone(target);
119
120 Class<?> cls = clone.getClass();
121 cls.getMethod("setUsePhrasedFileName", boolean.class).invoke(clone, getUsePhrasedFileName());
122 cls.getMethod("setUsePhrasedTestSuiteClassName", boolean.class)
123 .invoke(clone, getUsePhrasedTestSuiteClassName());
124 cls.getMethod("setUsePhrasedTestCaseClassName", boolean.class)
125 .invoke(clone, getUsePhrasedTestCaseClassName());
126 cls.getMethod("setUsePhrasedTestCaseMethodName", boolean.class)
127 .invoke(clone, getUsePhrasedTestCaseMethodName());
128
129 return clone;
130 } catch (ReflectiveOperationException e) {
131 throw new IllegalStateException(e.getLocalizedMessage());
132 }
133 }
134
135 @Override
136 public String toString() {
137 return "JUnit5Xml30StatelessReporter{"
138 + "version=" + getVersion()
139 + ", disable=" + isDisable()
140 + ", usePhrasedFileName=" + getUsePhrasedFileName()
141 + ", usePhrasedTestSuiteClassName=" + getUsePhrasedTestSuiteClassName()
142 + ", usePhrasedTestCaseClassName=" + getUsePhrasedTestCaseClassName()
143 + ", usePhrasedTestCaseMethodName=" + getUsePhrasedTestCaseMethodName()
144 + '}';
145 }
146 }