Skip to content

Commit 601ae81

Browse files
narenmanoharanbootstraponline
authored andcommitted
Disable FAIL_ON_UNKNOWN_PROPERTIES for forward compatibility (#599)
* Disable FAIL_ON_UNKNOWN_PROPERTIES to be compatible with future changes to the xml * Change to false * add test for unknown property * Fix detekt issue
1 parent b810da5 commit 601ae81

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

test_runner/src/main/kotlin/ftl/reports/xml/JUnitXml.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package ftl.reports.xml
33
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule
44
import com.fasterxml.jackson.dataformat.xml.XmlMapper
55
import com.fasterxml.jackson.module.kotlin.KotlinModule
6+
import com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES
67
import ftl.reports.xml.model.JUnitTestResult
78
import ftl.reports.xml.model.JUnitTestSuite
89
import java.io.File
@@ -12,6 +13,8 @@ import java.nio.file.Path
1213
private val xmlModule = JacksonXmlModule().apply { setDefaultUseWrapper(false) }
1314
private val xmlMapper = XmlMapper(xmlModule)
1415
.registerModules(KotlinModule())
16+
.configure(FAIL_ON_UNKNOWN_PROPERTIES, false)
17+
1518
private val xmlPrettyWriter = xmlMapper.writerWithDefaultPrettyPrinter()
1619

1720
private fun xmlBytes(path: Path): ByteArray {

test_runner/src/test/kotlin/ftl/reports/xml/JUnitXmlTest.kt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,32 @@ junit.framework.Assert.fail(Assert.java:50)</failure>
140140
)
141141
}
142142

143+
@Test
144+
fun `unknown xml property`() {
145+
val unknownXml = """
146+
<?xml version='1.0' encoding='UTF-8' ?>
147+
<testsuites>
148+
<testsuite random="prop" name="EarlGreyExampleSwiftTests" tests="4" failures="1" errors="0" skipped="0" time="51.773" hostname="localhost">
149+
<testcase name="a()" classname="a" time="1.0" random="prop"/>
150+
</testsuite>
151+
</testsuites>
152+
""".trimIndent()
153+
154+
val expected = """
155+
<?xml version='1.0' encoding='UTF-8' ?>
156+
<testsuites>
157+
<testsuite name="EarlGreyExampleSwiftTests" tests="4" failures="1" errors="0" skipped="0" time="51.773" hostname="localhost">
158+
<testcase name="a()" classname="a" time="1.0"/>
159+
</testsuite>
160+
</testsuites>
161+
162+
""".trimIndent()
163+
164+
val parsed = parseAllSuitesXml(unknownXml).xmlToString()
165+
166+
assertThat(parsed).isEqualTo(expected)
167+
}
168+
143169
@Test
144170
fun `junitXmlToString androidPassXml`() {
145171
val parsed = parseOneSuiteXml(androidPassXml).xmlToString()

0 commit comments

Comments
 (0)