From ddc4d76c41abfdc53609c5f7f8f4f8a9089a5b43 Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Tue, 28 Feb 2023 21:28:05 +0100 Subject: [PATCH] Lazily load activities in Robolectric tests (#3397) Not all Robolectric tests interact with activities, so lazy loading the activity can speed them up. I benchmarked the impact with gradle-profiler. Each test run performed 6 warmup runs, and then 10 benchmarked runs with and without this change. Without this change (all values rounded to nearest second): Mean: 151 Median: 149 P75: 157 StdDev: 10 With this change: Mean: 127 Median: 125 P75: 130 StdDev: 7 So a ~ 18% reduction in median and P75 times, --- app/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/app/build.gradle b/app/build.gradle index 3ca787049..d1259f72e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -72,6 +72,7 @@ android { } unitTests.all { systemProperty 'robolectric.logging.enabled', 'true' + systemProperty 'robolectric.lazyload', 'ON' } } sourceSets {