From b3faa7e59d50bfd7017d4ca0c7f707785eff56fa Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Sun, 17 Dec 2023 18:00:32 +0100 Subject: [PATCH] [SUREFIRE-1345] - Rename to hasFlakes and make list immutable --- .../maven/plugins/surefire/report/ReportTestCase.java | 7 ++++--- .../plugins/surefire/report/TestSuiteXmlParserTest.java | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/ReportTestCase.java b/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/ReportTestCase.java index 659ff7b135..c62e89b1f8 100644 --- a/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/ReportTestCase.java +++ b/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/ReportTestCase.java @@ -19,6 +19,7 @@ package org.apache.maven.plugins.surefire.report; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import static org.apache.maven.shared.utils.StringUtils.isNotBlank; @@ -168,7 +169,7 @@ public boolean hasSkipped() { return hasSkipped; } - public boolean hasFlake() { + public boolean hasFlakes() { return !flakyErrors.isEmpty() || !flakyFailures.isEmpty(); } @@ -177,7 +178,7 @@ public void addFlakyError(FlakyError flakyError) { } public List getFlakyErrors() { - return flakyErrors; + return Collections.unmodifiableList(flakyErrors); } public void addFlakyFailure(FlakyFailure flakyFailure) { @@ -185,7 +186,7 @@ public void addFlakyFailure(FlakyFailure flakyFailure) { } public List getFlakyFailures() { - return flakyFailures; + return Collections.unmodifiableList(flakyFailures); } /** diff --git a/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/TestSuiteXmlParserTest.java b/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/TestSuiteXmlParserTest.java index e67c0e1001..fd5e68e7ae 100644 --- a/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/TestSuiteXmlParserTest.java +++ b/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/TestSuiteXmlParserTest.java @@ -744,7 +744,7 @@ public void shouldParseFlakes() throws Exception { assertThat(tests.get(0).getTime(), is(0.034f)); assertThat(tests.get(0).getFullName(), is("org.acme.FlakyTest.testFlaky")); assertThat(tests.get(0).hasError(), is(false)); - assertThat(tests.get(0).hasFlake(), is(true)); + assertThat(tests.get(0).hasFlakes(), is(true)); List flakyFailures = tests.get(0).getFlakyFailures(); assertThat(flakyFailures.size(), is(3)); @@ -781,6 +781,6 @@ public void shouldParseFlakes() throws Exception { assertThat(tests.get(1).getTime(), is(0.001f)); assertThat(tests.get(1).getFullName(), is("org.acme.FlakyTest.testStable")); assertThat(tests.get(1).hasError(), is(false)); - assertThat(tests.get(1).hasFlake(), is(false)); + assertThat(tests.get(1).hasFlakes(), is(false)); } }