Code
The Unit Testing Diet Sample App – Behavior-Driven Development (BDD) example

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.
Setup
- Clone the repository
- Examine the structure of the tests in the
ChatViewModelSpec.kt
file.
Libraries Used
- Dependency Injection: Koin
- Testing Framework: Kotest
