Skip to content

Commit

Permalink
Disable FAIL_ON_UNKNOWN_PROPERTIES for forward compatibility (#599)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
narenmanoharan authored and bootstraponline committed Sep 11, 2019
1 parent b810da5 commit 601ae81
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test_runner/src/main/kotlin/ftl/reports/xml/JUnitXml.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ftl.reports.xml
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule
import com.fasterxml.jackson.dataformat.xml.XmlMapper
import com.fasterxml.jackson.module.kotlin.KotlinModule
import com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES
import ftl.reports.xml.model.JUnitTestResult
import ftl.reports.xml.model.JUnitTestSuite
import java.io.File
Expand All @@ -12,6 +13,8 @@ import java.nio.file.Path
private val xmlModule = JacksonXmlModule().apply { setDefaultUseWrapper(false) }
private val xmlMapper = XmlMapper(xmlModule)
.registerModules(KotlinModule())
.configure(FAIL_ON_UNKNOWN_PROPERTIES, false)

private val xmlPrettyWriter = xmlMapper.writerWithDefaultPrettyPrinter()

private fun xmlBytes(path: Path): ByteArray {
Expand Down
26 changes: 26 additions & 0 deletions test_runner/src/test/kotlin/ftl/reports/xml/JUnitXmlTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,32 @@ junit.framework.Assert.fail(Assert.java:50)</failure>
)
}

@Test
fun `unknown xml property`() {
val unknownXml = """
<?xml version='1.0' encoding='UTF-8' ?>
<testsuites>
<testsuite random="prop" name="EarlGreyExampleSwiftTests" tests="4" failures="1" errors="0" skipped="0" time="51.773" hostname="localhost">
<testcase name="a()" classname="a" time="1.0" random="prop"/>
</testsuite>
</testsuites>
""".trimIndent()

val expected = """
<?xml version='1.0' encoding='UTF-8' ?>
<testsuites>
<testsuite name="EarlGreyExampleSwiftTests" tests="4" failures="1" errors="0" skipped="0" time="51.773" hostname="localhost">
<testcase name="a()" classname="a" time="1.0"/>
</testsuite>
</testsuites>
""".trimIndent()

val parsed = parseAllSuitesXml(unknownXml).xmlToString()

assertThat(parsed).isEqualTo(expected)
}

@Test
fun `junitXmlToString androidPassXml`() {
val parsed = parseOneSuiteXml(androidPassXml).xmlToString()
Expand Down

0 comments on commit 601ae81

Please sign in to comment.