Speed Up Your Android Tests: Gradle Plugin for Unit Test Filtering
Article Summary
Wealthfront's Android team had a problem: their test suite was slowing down every PR merge. Running all tests on every change wasn't scaling.
The team built a custom Gradle plugin that intelligently filters unit tests based on changed files in each pull request. By leveraging their modular architecture and git diffs, they only run tests for affected modules instead of the entire suite.
Key Takeaways
- Test execution time dropped from 18 minutes to 11 minutes on PRs
- Achieved over 50% reduction in variable test costs (excluding compilation)
- Plugin uses git diff to identify changed modules and filter tests automatically
- Full test suite still runs on master before releases for complete coverage
- Modular architecture made filtering straightforward: change a module, test that module
Critical Insight
By running only relevant tests on PRs while keeping full coverage before releases, Wealthfront cut their unit test time in half without sacrificing quality.