viewmodel-testing-expert
CommunityExpert ViewModel testing with Turbine.
AuthorshaharKeisarApps
Version1.0.0
Installs0
System Documentation
What problem does it solve?
This skill provides a structured approach to unit testing Android ViewModels annotated with @HiltViewModel by leveraging Turbine for StateFlow testing, MainDispatcherRule for dispatcher control, and test doubles to simulate repository data.
Core Features & Use Cases
- Test StateFlow emissions: Validate loading, data, and error states in ViewModels using Turbine.
- Dispatcher management: Use MainDispatcherRule (or StandardTestDispatcher) to control coroutines during tests.
- Mock data sources: Drive repository responses with a FakeContentRepository to simulate success, loading, and error paths.
- Pagination and caching patterns: Verify accumulative data, refresh resets, and isFromCache indicators.
- Error handling and UX flows: Confirm error messages, and that errors can be dismissed via onErrorShown.
Quick Start
- Create a test class for your HiltViewModel, apply MainDispatcherRule, and write a Turbine-based test asserting StateFlow transitions using a FakeContentRepository.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: viewmodel-testing-expert Download link: https://github.com/shaharKeisarApps/MoviesAndBeyond/archive/main.zip#viewmodel-testing-expert Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.