Property-based testing in Android - are we testing like it's 1999?
summary
Argues that property-based testing catches faults value tests miss, demonstrating on a simple myMax function where Kotest (formerly KotlinTest) generators find a counterexample to a bad implementation, and showing ViewModel properties that replace three filter-specific unit tests with one rule that the add-button visibility equals filter==ALL. Uses checkAll/gen/arb/exhaustive generators, mocks and Mockito to capture LiveData emissions, converts JUnit rules to Kotest test listeners, and shows JUnit4 theories plus a custom RandomSupplier so property tests work without new libraries.
AI-written summary · about
chapters (14)
- 0:00Introduction and modern testing
- 1:13History of JVM testing
- 6:08Testing stagnation in 2016
- 7:11What is property-based testing
- 8:15Simple example with myMax function
- 10:24Limitations of value-based testing
- 11:25Exploring Kotest property checks
- 13:56Writing idiomatic property-based tests
- 17:31Testing Android ViewModels
- 21:48Modeling ViewModel actions
- 23:15Property-based ViewModel assertions
- 26:09Testing LiveData over time
- 28:12Property-based testing in JUnit
- 32:08Summary and Q&A
related talks
40mProperty‑Based UI Testing: Catching Edge Cases with Property Definitions Generated by LLMs
46mProperty-based testing:You won't look at your tests the same way ever again
47mProperty-based Testing or the Insufficiency of Unit Tests
41mHow to Really Test an Android Application
45mWhere do the Android tests belong?
17mProperty Based Testing: the real truth!
36mProperty Based Testing: From Theory to Practice
20mUnit testing on Android
