testing-guidelines

Standardizes Android/Kotlin unit and instrumentation testing with JUnit 4, MockK, and Turbine.

51|6|Updated Mar 10, 2019
One-click install
npx skills add https://github.com/AniTrend/anitrend-v2 --skill testing-guidelines-anitrend
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-guidelines
Source: https://github.com/AniTrend/anitrend-v2/tree/main/.agents/skills/testing-guidelines
Command: npx skills add https://github.com/AniTrend/anitrend-v2 --skill testing-guidelines-anitrend

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It reduces flakey or incomplete test coverage by prescribing a consistent strategy for unit and instrumentation testing across DataState flows, repositories, ViewModels, and WorkManager logic.

Core Features & Use Cases

  • JUnit + MockK + Turbine flow testing: Standardizes how to test emitted DataState/Flow sequences deterministically.
  • Koin-focused validation patterns: Guides you to verify DI wiring safely and narrowly, using resolution tests alongside behavior tests.
  • WorkManager testing approach: Recommends testing worker logic via direct internal logic calls and using WorkManager test helpers only when necessary.

Quick Start

Use the testing-guidelines skill when you are adding or refactoring tests for DataState flows, repositories, ViewModels, or WorkManager tasks in AniTrend v2.0.

Frequently Asked Questions about testing-guidelines

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

FAQPage Schema
How do I test Kotlin Flow emissions deterministically?

Test Kotlin Flow emissions deterministically by combining Turbine with kotlinx-coroutines-test runTest patterns. This standardizes how to verify emitted DataState sequences, ensuring your unit tests remain fast, safe, and maintainable.

What is the best way to validate Koin dependency injection wiring in tests?

Validate Koin dependency injection wiring safely and narrowly by using repo-specific checkModules and narrow-module resolution tests. This approach verifies your DI configuration without coupling tests to broader application modules.

How do I test WorkManager logic without flaky instrumentation tests?

Test WorkManager logic without flakiness by calling internal worker logic directly for behavior verification. Reserve WorkManager test helpers only for specific scenarios where framework-level execution validation is absolutely necessary.

Can I use MockK for repository and ViewModel behavior verification?

Yes, you can use MockK for repository and ViewModel behavior verification. It standardizes unit and instrumentation testing practices across Android and Kotlin codebases, ensuring consistent mocking and deterministic test coverage.

What testing frameworks do I need for Android DataState unit tests?

You need JUnit 4, MockK, and Turbine to execute Android DataState unit tests. These dependencies provide the foundational structure, mocking capabilities, and flow testing utilities required for deterministic test suites.

Why are my Turbine flow tests failing intermittently?

Intermittent Turbine flow test failures often stem from non-deterministic emission sequences. Standardizing on kotlinx-coroutines-test runTest patterns ensures consistent test execution, reducing flakey or incomplete DataState flow coverage.