Testing Legacy Strategies

Add characterization tests to legacy codebases using Robolectric, MockK, and Detekt baselines.

9|1|Updated Jan 26, 2026
One-click install
npx skills add https://github.com/BryantChi/Android-Skills --skill testing-legacy-strategies
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Testing Legacy Strategies
Source: https://github.com/BryantChi/Android-Skills/tree/main/testing_legacy_strategies
Command: npx skills add https://github.com/BryantChi/Android-Skills --skill testing-legacy-strategies

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides a structured approach to adding tests to existing codebases that lack test coverage, mitigating the risks associated with refactoring and modernization.

Core Features & Use Cases

  • Characterization Tests: Capture the current behavior of legacy code to establish a baseline.
  • Framework Testing: Utilize Robolectric for testing Android framework-dependent components.
  • Mocking Strategies: Employ MockK for effective mocking of Kotlin code, including coroutines.
  • Quality Gates: Implement Detekt/Lint baselines to incrementally enforce coding standards.
  • Golden Master Testing: Verify complex outputs like HTML or JSON against a known good state.
  • Use Case: You have a critical but untested module in a legacy Android application. Use this Skill to first write characterization tests to understand its current behavior, then add Robolectric tests for framework interactions, and finally use MockK to isolate dependencies, creating a safety net before making changes.

Quick Start

Use the testing legacy strategies skill to create characterization tests for the LegacyCalculator class.

Frequently Asked Questions about Testing Legacy Strategies

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

FAQPage Schema
What are characterization tests and when do I need them for legacy code?

Characterization tests capture the current behavior of legacy code to establish a safety baseline. You need them before refactoring untested codebases to ensure existing functionality remains stable during modernization.

How do I add tests to legacy Android applications lacking test coverage?

To add tests to legacy Android applications, utilize Robolectric for testing framework-dependent components and MockK for mocking Kotlin code. This creates an isolated testing safety net for critical untested modules.

Can I use MockK for mocking Kotlin coroutines in legacy codebases?

Yes, you can use MockK for mocking Kotlin coroutines in legacy codebases. It provides effective mocking strategies specifically for Kotlin code, allowing you to isolate dependencies before modifying shared logic.

What is the best way to verify complex outputs during legacy code refactoring?

The best way to verify complex outputs during legacy code refactoring is Golden Master testing. This technique checks outputs like HTML or JSON against a known good state to detect unexpected behavioral changes.

How do I incrementally enforce coding standards on an old untested project?

You incrementally enforce coding standards on old projects by implementing Detekt and Lint baselines. These quality gates establish a threshold for current code quality, allowing you to address new violations without fixing historical issues immediately.