fix(android): testOptions isReturnDefaultValues = true
android / Build + lint + test (push) Failing after 2m55s
android / Build + lint + test (push) Failing after 2m55s
Unit tests touching Android framework statics (Bundle.EMPTY, android.os.Bundle constructor in MediaItem/SessionCommand construction) failed with NPE/ExceptionInInitializerError because JVM unit tests run against android.jar's stub classes whose methods throw "Method ... not mocked" by default. Enable isReturnDefaultValues so stub methods return defaults — Bundle.EMPTY ends up null and is fine because we just thread it through SessionCommand without inspecting it. Fixes LikeMediaCallbackTest's 5 failures on run #311. Lightweight — no Robolectric, no androidTest. The first JVM-side test file in the project to touch Android framework classes.
This commit is contained in:
@@ -80,6 +80,19 @@ android {
|
|||||||
buildConfig = true
|
buildConfig = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testOptions {
|
||||||
|
unitTests {
|
||||||
|
// JVM unit tests run against android.jar's stub methods,
|
||||||
|
// which throw `RuntimeException("Method ... not mocked")`
|
||||||
|
// when touched (including statics like Bundle.EMPTY).
|
||||||
|
// Return defaults instead so tests that pass Bundles
|
||||||
|
// through without inspecting them (e.g. SessionCommand
|
||||||
|
// construction in LikeMediaCallbackTest) just work,
|
||||||
|
// without dragging in Robolectric.
|
||||||
|
isReturnDefaultValues = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
packaging {
|
packaging {
|
||||||
resources.excludes +=
|
resources.excludes +=
|
||||||
setOf(
|
setOf(
|
||||||
|
|||||||
Reference in New Issue
Block a user