Skip to content

Repository files navigation

This repository contains sample code for testing an Android application using the MVVM architecture with ViewModel, LiveData, and Repository patterns. The focus is on unit testing and UI testing in the To-Do app.

Self Introduction

  • Name: Phan Dinh Trung.

  • StudentID: 22110083.

Overview

  • This project is part of Google's Advanced Android Testing course, demonstrating best practices for writing tests in Android applications. The code includes unit tests, instrumentation tests, and UI tests using JUnit, Mockito, and Espresso.

TasksViewModelTest.kt

The TasksViewModelTest.kt file contains unit tests for the TasksViewModel class, ensuring that the ViewModel functions correctly under various scenarios.

Key Features

  • Utilizes JUnit and Mockito for unit testing.

  • Tests ViewModel logic without requiring a real UI or database.

  • Verifies LiveData updates correctly.

  • Mocks repository dependencies to isolate ViewModel behavior.

Example Test Cases

  • Checking whether the ViewModel loads tasks correctly.

  • Filtering active and completed tasks.

  • Validating empty states and error handling.

Technologies Used

Kotlin as the programming language.

  • Android ViewModel for UI-related data management.

  • LiveData for observable data streams.

  • JUnit for unit testing.

  • Mockito for dependency mocking.

  • Espresso for UI testing.

Running the Tests

To execute the tests:

  • Open the project in Android Studio.

  • Ensure that the project is built using JDK version 11 by navigating to File → Settings → Build, Execution, Deployment → Build Tools → Gradle and selecting JDK 11.

  • Navigate to TasksViewModelTest.kt or StatisticsUtilsTest.kt.

  • Select the test function you want to run and execute it.

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages