File tree 2 files changed +42
-0
lines changed
main/kotlin/ftl/domain/junit
test/kotlin/ftl/client/xml
2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,13 @@ fun JUnitTest.Suite.merge(other: JUnitTest.Suite): JUnitTest.Suite {
47
47
this .errors = mergeInt(this .errors, other.errors)
48
48
this .skipped = mergeInt(this .skipped, other.skipped)
49
49
this .time = mergeDouble(this .time, other.time)
50
+ if (other.flakes != null ) {
51
+ this .flakes = mergeInt(
52
+ this .flakes?.toString(),
53
+ other.flakes?.toString()
54
+ ).toInt()
55
+ }
56
+
50
57
51
58
if (this .testcases == null ) this .testcases = mutableListOf ()
52
59
if (other.testcases?.isNotEmpty() == true ) {
Original file line number Diff line number Diff line change @@ -30,6 +30,15 @@ class JUnitXmlTest {
30
30
<skipped/>
31
31
</testcase>
32
32
<testcase name="testPasses" classname="com.example.app.ExampleUiTest" time="0.001"/>
33
+ </testsuite>
34
+ """ .trimIndent()
35
+ val flakyTestSuiteXml = """
36
+ <testsuite name="" tests="2" failures="0" flakes="1" errors="0" skipped="0" time="0.026" timestamp="2018-10-26T19:57:28" hostname="localhost">
37
+ <properties/>
38
+ <testcase name="testFails" classname="com.example.app.ExampleUiTest" time="0.0">
39
+ <skipped/>
40
+ </testcase>
41
+ <testcase name="testPasses" classname="com.example.app.ExampleUiTest" time="0.001"/>
33
42
</testsuite>
34
43
""" .trimIndent()
35
44
}
@@ -525,6 +534,32 @@ junit.framework.Assert.fail(Assert.java:50)</failure>
525
534
val oneSuiteXml = parseOneSuiteXml(crashingOneSuiteMessage.writeToTempFile()).toXmlString().trimIndent()
526
535
Assert .assertEquals(" One Suite Messages should be the same!" , expectedOneSuiteMessage, oneSuiteXml)
527
536
}
537
+
538
+ @Test
539
+ fun `merge flakes` () {
540
+ val merged = parseOneSuiteXml(flakyTestSuiteXml.writeToTempFile())
541
+ merged.merge(merged)
542
+ val actual = merged.toXmlString().normalizeLineEnding()
543
+
544
+ assertThat(actual).isEqualTo(
545
+ """
546
+ <?xml version='1.0' encoding='UTF-8' ?>
547
+ <testsuites>
548
+ <testsuite name="" tests="4" failures="0" flakes="2" errors="0" skipped="0" time="0.052" timestamp="2018-10-26T19:57:28" hostname="localhost">
549
+ <testcase name="testFails" classname="com.example.app.ExampleUiTest" time="0.0">
550
+ <skipped/>
551
+ </testcase>
552
+ <testcase name="testPasses" classname="com.example.app.ExampleUiTest" time="0.001"/>
553
+ <testcase name="testFails" classname="com.example.app.ExampleUiTest" time="0.0">
554
+ <skipped/>
555
+ </testcase>
556
+ <testcase name="testPasses" classname="com.example.app.ExampleUiTest" time="0.001"/>
557
+ </testsuite>
558
+ </testsuites>
559
+
560
+ """ .trimIndent()
561
+ )
562
+ }
528
563
}
529
564
530
565
private fun String.writeToTempFile (): File = File .createTempFile(" temp" , " test" )
You can’t perform that action at this time.
0 commit comments