Stop Wasting Time on Unit Testing: How Tokopedia Achieved 8X Faster Results | by Andrean Lay | Tokopedia Engineering | Medium
Article Summary
Tokopedia's iOS team was drowning in 30-minute unit test cycles with 65 developers fighting over 9 CI/CD machines. They cut that time by 8X.
Andrean Lay from Tokopedia Engineering shares their journey from running all unit tests sequentially to implementing selective testing. With hundreds of test targets and tens of thousands of test cases, their modular Bazel-based iOS app needed a smarter approach.
Key Takeaways
- Unified all test targets into one, dropping median time from 1772s to 563s
- Selective testing runs only affected modules and reverse dependencies
- Some PRs now achieve zero test time when changes don't impact code
- Final median test duration: 250s, with 8X overall improvement from baseline
By testing only what changed plus its dependents, Tokopedia reduced unit test time from 30+ minutes to under 5 minutes on average.
About This Article
Tokopedia's iOS app on Bazel had hundreds of test targets, and the build process overhead repeated for each one. This made test times unpredictable, ranging anywhere from 20 to 35 minutes with occasional spikes.
Andrean Lay's team built a three-step approach to selective testing. They compared file changes, extracted affected target paths from BUILD files, and used Bazel's allrdeps command to find reverse dependencies. This way they only ran the modules that actually changed.
Selective testing cut median unit test duration down to 250 seconds. When changes only touched non-code files like GitHub code owner configurations, tests ran in zero seconds. Overall, this achieved an 8X improvement in speed.