How can you effectively unit test an MVVM app at scale?
This is a sample Android chat application that demonstrates how to follow Behavior-Driven Development (BDD), by writing unit tests that test the behavior that a user performs and the outcome that they perceive, without testing implementation details.
The tests are written in the Given-When-Then style and they cover the ViewModel, UseCase, and Repository layers, without using mocks.
For a comprehensive guide on how to follow this methodology, please refer to the "Unit Testing Diet" blog post.
- Clone the repository
- Checkout the
main
branch for Kotlin Flow orrxjava
for RxJava - Examine the structure of the tests in the
ChatViewModelSpec.kt
file.
- Dependency Injection: Koin
- Testing Framework: Kotest
- Reactive Framework: Both Kotlin Flow and RxJava are supported
For further queries or feedback, feel free to reach out to me on Twitter: @SteliosFran.