File tree Expand file tree Collapse file tree
main/kotlin/ftl/reports/xml
test/kotlin/ftl/reports/xml Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package ftl.reports.xml
33import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule
44import com.fasterxml.jackson.dataformat.xml.XmlMapper
55import com.fasterxml.jackson.module.kotlin.KotlinModule
6+ import com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES
67import ftl.reports.xml.model.JUnitTestResult
78import ftl.reports.xml.model.JUnitTestSuite
89import java.io.File
@@ -12,6 +13,8 @@ import java.nio.file.Path
1213private val xmlModule = JacksonXmlModule ().apply { setDefaultUseWrapper(false ) }
1314private val xmlMapper = XmlMapper (xmlModule)
1415 .registerModules(KotlinModule ())
16+ .configure(FAIL_ON_UNKNOWN_PROPERTIES , false )
17+
1518private val xmlPrettyWriter = xmlMapper.writerWithDefaultPrettyPrinter()
1619
1720private fun xmlBytes (path : Path ): ByteArray {
Original file line number Diff line number Diff 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()
You can’t perform that action at this time.
0 commit comments