diff --git a/test_runner/src/main/kotlin/ftl/domain/junit/JUnitTestMerge.kt b/test_runner/src/main/kotlin/ftl/domain/junit/JUnitTestMerge.kt index 40bd98f321..c2470d5ae1 100644 --- a/test_runner/src/main/kotlin/ftl/domain/junit/JUnitTestMerge.kt +++ b/test_runner/src/main/kotlin/ftl/domain/junit/JUnitTestMerge.kt @@ -47,6 +47,13 @@ fun JUnitTest.Suite.merge(other: JUnitTest.Suite): JUnitTest.Suite { this.errors = mergeInt(this.errors, other.errors) this.skipped = mergeInt(this.skipped, other.skipped) this.time = mergeDouble(this.time, other.time) + if (other.flakes != null) { + this.flakes = mergeInt( + this.flakes?.toString(), + other.flakes?.toString() + ).toInt() + } + if (this.testcases == null) this.testcases = mutableListOf() if (other.testcases?.isNotEmpty() == true) { diff --git a/test_runner/src/test/kotlin/ftl/client/xml/JUnitXmlTest.kt b/test_runner/src/test/kotlin/ftl/client/xml/JUnitXmlTest.kt index 8aff7fb981..a24088eef0 100644 --- a/test_runner/src/test/kotlin/ftl/client/xml/JUnitXmlTest.kt +++ b/test_runner/src/test/kotlin/ftl/client/xml/JUnitXmlTest.kt @@ -30,6 +30,15 @@ class JUnitXmlTest { + + """.trimIndent() + val flakyTestSuiteXml = """ + + + + + + """.trimIndent() } @@ -525,6 +534,32 @@ junit.framework.Assert.fail(Assert.java:50) val oneSuiteXml = parseOneSuiteXml(crashingOneSuiteMessage.writeToTempFile()).toXmlString().trimIndent() Assert.assertEquals("One Suite Messages should be the same!", expectedOneSuiteMessage, oneSuiteXml) } + + @Test + fun `merge flakes`() { + val merged = parseOneSuiteXml(flakyTestSuiteXml.writeToTempFile()) + merged.merge(merged) + val actual = merged.toXmlString().normalizeLineEnding() + + assertThat(actual).isEqualTo( + """ + + + + + + + + + + + + + + + """.trimIndent() + ) + } } private fun String.writeToTempFile(): File = File.createTempFile("temp", "test")