@@ -47,19 +47,8 @@ public class FlakyTestReporter {
47
47
private int errorCount ;
48
48
private final List <FlakyTest > flakyTests = new ArrayList <>();
49
49
50
- private static class FlakyTest {
51
- final String testClassName ;
52
- final String testName ;
53
- final String timestamp ;
54
- final String message ;
55
-
56
- FlakyTest (String testClassName , String testName , String timestamp , String message ) {
57
- this .testClassName = testClassName ;
58
- this .testName = testName ;
59
- this .timestamp = timestamp ;
60
- this .message = message ;
61
- }
62
- }
50
+ private record FlakyTest (
51
+ String testClassName , String testName , String timestamp , String message ) {}
63
52
64
53
private void addFlakyTest (
65
54
String testClassName , String testName , String timestamp , String message ) {
@@ -160,6 +149,15 @@ private static String getAttributeValue(Node node, String attributeName) {
160
149
return value != null ? value .getNodeValue () : null ;
161
150
}
162
151
152
+ private static class BaseFileVisitor <T > extends SimpleFileVisitor <T > {
153
+ @ Override
154
+ public FileVisitResult visitFileFailed (T file , IOException exception ) {
155
+ System .err .println ("Failed to visit " + file .toString ());
156
+ exception .printStackTrace ();
157
+ return CONTINUE ;
158
+ }
159
+ }
160
+
163
161
private void scanTestResults (Path buildDir ) throws IOException {
164
162
Path testResults = buildDir .resolve ("test-results" );
165
163
if (!Files .exists (testResults )) {
@@ -168,7 +166,7 @@ private void scanTestResults(Path buildDir) throws IOException {
168
166
169
167
Files .walkFileTree (
170
168
testResults ,
171
- new SimpleFileVisitor <>() {
169
+ new BaseFileVisitor <>() {
172
170
@ Override
173
171
public FileVisitResult visitFile (Path file , BasicFileAttributes attrs ) {
174
172
String name = file .getFileName ().toString ();
@@ -178,21 +176,14 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
178
176
179
177
return CONTINUE ;
180
178
}
181
-
182
- @ Override
183
- public FileVisitResult visitFileFailed (Path file , IOException exception ) {
184
- System .err .println ("Failed to visit " + file .toString ());
185
- exception .printStackTrace ();
186
- return CONTINUE ;
187
- }
188
179
});
189
180
}
190
181
191
182
private static FlakyTestReporter scan (Path path ) throws IOException {
192
183
FlakyTestReporter reporter = new FlakyTestReporter ();
193
184
Files .walkFileTree (
194
185
path ,
195
- new SimpleFileVisitor <>() {
186
+ new BaseFileVisitor <>() {
196
187
@ Override
197
188
public FileVisitResult preVisitDirectory (Path dir , BasicFileAttributes attrs )
198
189
throws IOException {
0 commit comments