testing-android-code

Provide Android test patterns and base classes for Bitwarden ViewModel, Compose UI, and service tests.

9.2k|1.0k|Updated Apr 30, 2016
One-click install
npx skills add https://github.com/bitwarden/android --skill testing-android-code
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-android-code
Source: https://github.com/bitwarden/android/tree/main/.claude/skills/testing-android-code
Command: npx skills add https://github.com/bitwarden/android --skill testing-android-code

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Bitwarden Android test workflows can be complex and brittle. This skill consolidates proven testing patterns, base test classes, and utilities to streamline writing reliable unit and UI tests for Android code in Bitwarden.

Core Features & Use Cases

  • Base classes and patterns for ViewModel, Compose UI, and service tests (BaseViewModelTest, BitwardenComposeTest, BaseServiceTest)
  • Turbine-based testing guidance for StateFlow vs EventFlow and test data builders
  • Extensive test data builders (createMockCipher, createMockSyncResponse, etc.) and fake implementations
  • Illustrated examples and reference docs for common scenarios (ViewModel tests, Compose screen tests, repository tests)

Quick Start

Use this skill to get started with Android test patterns; for example, ask: "How do I test a ViewModel with a StateFlow and EventFlow using BaseViewModelTest?"

Frequently Asked Questions about testing-android-code

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test an Android ViewModel with StateFlow and EventFlow?

To test an Android ViewModel with StateFlow and EventFlow, use the BaseViewModelTest class alongside Turbine to verify reactive stream emissions. This pattern provides structured coroutine test support and mock data builders for consistent results.

What's the best way to write Compose UI tests for Bitwarden Android?

Compose UI tests for Bitwarden Android are best handled through the BitwardenComposeTest base class. It establishes consistent UI testing conventions and provides utilities to streamline reliable component and screen tests.

Do I need JUnit 5 and MockK for Bitwarden Android testing?

Yes, JUnit 5 and MockK are required dependencies for Bitwarden Android testing. You also need Turbine and coroutine test support to properly handle StateFlow, EventFlow, and asynchronous operations.

How do I create mock cipher data for Android repository tests?

Create mock cipher data for repository tests using provided test data builders like createMockCipher and createMockSyncResponse. These utilities ensure consistent fake implementations across service and repository test suites.

Why does my Turbine test fail when verifying StateFlow vs EventFlow?

Turbine tests fail when StateFlow and EventFlow are treated interchangeably, as StateFlow conflates values while EventFlow broadcasts one-time events. Following Bitwarden base test patterns ensures correct stream verification.