Skip to content

Commit 0a33e5e

Browse files
committed
back to record as this was not the problem
Signed-off-by: Olivier Lamy <[email protected]>
1 parent dca551b commit 0a33e5e

File tree

3 files changed

+27
-134
lines changed

3 files changed

+27
-134
lines changed

src/main/java/hudson/tasks/junit/FlakyFailure.java

Lines changed: 2 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -4,60 +4,5 @@
44
import org.kohsuke.stapler.export.ExportedBean;
55

66
@ExportedBean
7-
public class FlakyFailure implements Serializable {
8-
private String message;
9-
private String type;
10-
private String stackTrace;
11-
private String stdout;
12-
private String stderr;
13-
14-
public FlakyFailure() {}
15-
16-
public FlakyFailure(String message, String type, String stackTrace, String stdout, String stderr) {
17-
this.message = message;
18-
this.type = type;
19-
this.stackTrace = stackTrace;
20-
this.stdout = stdout;
21-
this.stderr = stderr;
22-
}
23-
24-
public String getMessage() {
25-
return message;
26-
}
27-
28-
public void setMessage(String message) {
29-
this.message = message;
30-
}
31-
32-
public String getType() {
33-
return type;
34-
}
35-
36-
public void setType(String type) {
37-
this.type = type;
38-
}
39-
40-
public String getStackTrace() {
41-
return stackTrace;
42-
}
43-
44-
public void setStackTrace(String stackTrace) {
45-
this.stackTrace = stackTrace;
46-
}
47-
48-
public String getStdout() {
49-
return stdout;
50-
}
51-
52-
public void setStdout(String stdout) {
53-
this.stdout = stdout;
54-
}
55-
56-
public String getStderr() {
57-
return stderr;
58-
}
59-
60-
public void setStderr(String stderr) {
61-
this.stderr = stderr;
62-
}
63-
}
7+
public record FlakyFailure(String message, String type, String stackTrace, String stdout, String stderr)
8+
implements Serializable {}
Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,8 @@
11
package hudson.tasks.junit;
22

33
import java.io.Serializable;
4+
import org.kohsuke.stapler.export.ExportedBean;
45

5-
public class RerunFailure implements Serializable {
6-
private String message;
7-
private String type;
8-
private String stackTrace;
9-
private String stdout;
10-
private String stderr;
11-
12-
public RerunFailure() {}
13-
14-
public RerunFailure(String message, String type, String stackTrace, String stdout, String stderr) {
15-
this.message = message;
16-
this.type = type;
17-
this.stackTrace = stackTrace;
18-
this.stdout = stdout;
19-
this.stderr = stderr;
20-
}
21-
22-
public String getMessage() {
23-
return message;
24-
}
25-
26-
public void setMessage(String message) {
27-
this.message = message;
28-
}
29-
30-
public String getType() {
31-
return type;
32-
}
33-
34-
public void setType(String type) {
35-
this.type = type;
36-
}
37-
38-
public String getStackTrace() {
39-
return stackTrace;
40-
}
41-
42-
public void setStackTrace(String stackTrace) {
43-
this.stackTrace = stackTrace;
44-
}
45-
46-
public String getStdout() {
47-
return stdout;
48-
}
49-
50-
public void setStdout(String stdout) {
51-
this.stdout = stdout;
52-
}
53-
54-
public String getStderr() {
55-
return stderr;
56-
}
57-
58-
public void setStderr(String stderr) {
59-
this.stderr = stderr;
60-
}
61-
}
6+
@ExportedBean
7+
public record RerunFailure(String message, String type, String stackTrace, String stdout, String stderr)
8+
implements Serializable {}

src/test/java/hudson/tasks/junit/TestResultTest.java

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,11 @@ void bigResultReadWrite() throws Exception {
450450
.toList();
451451

452452
assertEquals(2, flakyFailures.size());
453-
assertNotNull(flakyFailures.get(0).getMessage());
454-
assertNotNull(flakyFailures.get(0).getType());
455-
assertNotNull(flakyFailures.get(0).getStackTrace());
456-
assertNotNull(flakyFailures.get(0).getStdout());
457-
assertNotNull(flakyFailures.get(0).getStderr());
453+
assertNotNull(flakyFailures.get(0).message());
454+
assertNotNull(flakyFailures.get(0).type());
455+
assertNotNull(flakyFailures.get(0).stackTrace());
456+
assertNotNull(flakyFailures.get(0).stdout());
457+
assertNotNull(flakyFailures.get(0).stderr());
458458

459459
XmlFile f = new XmlFile(TestResultAction.XSTREAM, File.createTempFile("junitResult.xml", null, tmp));
460460
f.write(tr);
@@ -495,7 +495,9 @@ void bigResultReadWrite() throws Exception {
495495
.map(Difference::toString)
496496
.toList()));
497497
boolean isTwoEqual = FileUtils.contentEquals(f.getFile(), f2.getFile());
498-
assertTrue(isTwoEqual, "Forgot to implement XML parsing for something?");
498+
assertTrue(
499+
isTwoEqual,
500+
"Forgot to implement XML parsing for something? Forgot to implement XML parsing for something?");
499501
}
500502

501503
@Issue("GH-237")
@@ -525,11 +527,11 @@ void includeFlakyAndRerun() throws Exception {
525527
.getFlakyFailures()
526528
.get(0);
527529
assertNotNull(flakyFailure);
528-
assertEquals("junit.framework.AssertionFailedError", flakyFailure.getType());
529-
assertEquals("obvious fail", flakyFailure.getMessage());
530-
assertTrue(flakyFailure.getStackTrace().contains("at io.olamy.FlakyTest.testApp(FlakyTest.java:27)"));
531-
assertEquals("this will fail maybe", flakyFailure.getStdout().trim());
532-
assertEquals("this will maybe fail", flakyFailure.getStderr().trim());
530+
assertEquals("junit.framework.AssertionFailedError", flakyFailure.type());
531+
assertEquals("obvious fail", flakyFailure.message());
532+
assertTrue(flakyFailure.stackTrace().contains("at io.olamy.FlakyTest.testApp(FlakyTest.java:27)"));
533+
assertEquals("this will fail maybe", flakyFailure.stdout().trim());
534+
assertEquals("this will maybe fail", flakyFailure.stderr().trim());
533535

534536
TestResult tr = new TestResult();
535537
tr.getSuites().add(flakySuiteResult);
@@ -552,7 +554,7 @@ void includeFlakyAndRerun() throws Exception {
552554
// fileDiff.getDifferences().forEach(System.out::println);
553555
assertFalse(
554556
fileDiff.hasDifferences(),
555-
"XML files are different:"
557+
"Forgot to implement XML parsing for something? XML files are different:"
556558
+ String.join(
557559
"\n",
558560
StreamSupport.stream(
@@ -580,13 +582,12 @@ void includeFlakyAndRerun() throws Exception {
580582
.getRerunFailures()
581583
.get(0);
582584
assertNotNull(rerunFailure);
583-
assertEquals("junit.framework.AssertionFailedError", rerunFailure.getType());
584-
assertEquals("built to fail", rerunFailure.getMessage());
585-
assertTrue(rerunFailure
586-
.getStackTrace()
587-
.contains("at io.olamy.AlwaysFailTest.testApp(AlwaysFailTest.java:23)"));
588-
assertEquals("this will fail for real", rerunFailure.getStdout().trim());
589-
assertEquals("this will really fail", rerunFailure.getStderr().trim());
585+
assertEquals("junit.framework.AssertionFailedError", rerunFailure.type());
586+
assertEquals("built to fail", rerunFailure.message());
587+
assertTrue(
588+
rerunFailure.stackTrace().contains("at io.olamy.AlwaysFailTest.testApp(AlwaysFailTest.java:23)"));
589+
assertEquals("this will fail for real", rerunFailure.stdout().trim());
590+
assertEquals("this will really fail", rerunFailure.stderr().trim());
590591

591592
TestResult tr = new TestResult();
592593
tr.getSuites().add(rerunSuite);
@@ -608,7 +609,7 @@ void includeFlakyAndRerun() throws Exception {
608609

609610
assertFalse(
610611
fileDiff.hasDifferences(),
611-
"XML files are different:"
612+
"Forgot to implement XML parsing for something? XML files are different:"
612613
+ String.join(
613614
"\n",
614615
StreamSupport.stream(

0 commit comments

Comments
 (0)