Connect with us

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

  1. Clone the repository
  2. Examine the structure of the tests in the ChatViewModelSpec.kt file.

Libraries Used

The Unit Testing Diet Sample App on GitHub: https://github.com/steliosfran/unit-testing-diet
Platform: Android
⭐️: 7
Advertisement

Trending