fix(android): UPnP - add kxml2 to test classpath so DeviceDescriptionTest runs
android / Build + lint + test (push) Successful in 4m7s
android / Build + lint + test (push) Successful in 4m7s
Android's XmlPullParserFactory is a Stub-throwing class in android.jar
on the JVM unit-test classpath; the probe pattern from dc5b8252 was
silently skipping the test suite, which gives false test-coverage
confidence. kxml2 is the same parser implementation Android uses
internally - service-provider lookup picks it up automatically once
on the test classpath.
The probe + Assumptions.assumeTrue skip removed; tests now run
unconditionally.
testImplementation(libs.kxml2) - 2.3.0, MIT-licensed, ~80KB. No
production code change.
This commit is contained in:
+3
-15
@@ -1,10 +1,7 @@
|
||||
package com.fabledsword.minstrel.player.output.upnp
|
||||
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import org.junit.jupiter.api.Assumptions.assumeTrue
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.xmlpull.v1.XmlPullParserFactory
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNotNull
|
||||
import kotlin.test.assertNull
|
||||
@@ -14,23 +11,14 @@ import kotlin.test.assertNull
|
||||
*
|
||||
* Android's stock `XmlPullParserFactory.newInstance()` resolves to a
|
||||
* real impl on-device but resolves to the android.jar stub class on
|
||||
* JVM unit tests unless an org.xmlpull impl (kxml2) is present on the
|
||||
* test classpath. The @BeforeEach probe skips the suite gracefully on
|
||||
* runners where the factory can't be constructed — keeps CI green on
|
||||
* minimal classpaths while still running the assertions when the
|
||||
* impl IS available (Android instrumentation, Robolectric, or any
|
||||
* runner that bundles kxml2 transitively).
|
||||
* JVM unit tests. kxml2 is added as a testImplementation dep so
|
||||
* `XmlPullParserFactory.newInstance()` finds it via service-provider
|
||||
* lookup on the test classpath; the tests run unconditionally.
|
||||
*/
|
||||
class DeviceDescriptionTest {
|
||||
|
||||
private val base = "http://192.168.1.50:1400/xml/device_description.xml".toHttpUrl()
|
||||
|
||||
@BeforeEach
|
||||
fun skipIfStubFactory() {
|
||||
val ok = runCatching { XmlPullParserFactory.newInstance().newPullParser() }.isSuccess
|
||||
assumeTrue(ok, "XmlPullParserFactory unavailable on this JVM classpath")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `parses Sonos-shaped description`() {
|
||||
val xml = """
|
||||
|
||||
Reference in New Issue
Block a user