@@ -421,6 +421,31 @@ android {
421421 }
422422 lint {
423423 abortOnError true
424+ // Lint analyzes main, androidTest and unitTest sources of the variant by
425+ // default; the unitTest analysis (lintAnalyze<Variant>UnitTest) take more time
426+ // to complete. Restrict lint to the variant's main sources.
427+ ignoreTestSources true
428+ }
429+
430+ testOptions {
431+ unitTests {
432+ // Plain JVM unit tests load the stubbed android.jar, whose methods
433+ // throw "not mocked" by default.
434+ returnDefaultValues = true
435+ // NOTE: includeAndroidResources is intentionally left disabled.
436+ // Enabling it makes Robolectric inflate the real manifest, which
437+ // instantiates the app Application (initializes the gojni native
438+ // backend, unavailable on the JVM) and breaks Material-themed
439+ // activity tests.
440+ }
441+ }
442+
443+ // Test-task tuning is done lazily on the task container (configureEach)
444+ // instead of unitTests.all {} to avoid eager configuration.
445+ tasks. withType(Test ). configureEach {
446+ // Robolectric sandboxes across ~1200 tests exceed the 512m
447+ // default, causing spurious OOMs in classes that run late.
448+ maxHeapSize = " 2g"
424449 }
425450
426451 // ------------------------------------------------------------------
@@ -584,7 +609,7 @@ dependencies {
584609 androidTestImplementation ' androidx.test.espresso:espresso-core:3.7.0'
585610 androidTestImplementation ' androidx.test.espresso:espresso-accessibility:3.7.0'
586611 androidTestImplementation ' androidx.test:rules:1.7.0'
587- testImplementation ' org.robolectric:robolectric:4.16.1 '
612+ testImplementation ' org.robolectric:robolectric:4.17 '
588613 testImplementation ' androidx.test:core:1.7.0'
589614 testImplementation ' androidx.test.ext:junit:1.3.0'
590615 testImplementation ' org.mockito:mockito-core:5.23.0'
0 commit comments