migrate-harness-tests-to-state-transition-test

Migrate ops.testing Harness test suites to state-transition tests for Juju events.

29|22|Updated Nov 25, 2025
One-click install
npx skills add https://github.com/canonical/copilot-collections --skill migrate-harness-tests-to-state-transition-test
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migrate-harness-tests-to-state-transition-test
Source: https://github.com/canonical/copilot-collections/tree/main/assets/skills/migrate-harness-tests-to-state-transition-test
Command: npx skills add https://github.com/canonical/copilot-collections --skill migrate-harness-tests-to-state-transition-test

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill helps charm developers update their unit tests from the deprecated ops.testing.Harness framework to the modern, event-driven state-transition tests, ensuring compatibility with current Juju releases.

Core Features & Use Cases

  • Harness Detection: Identifies all usages of ops.testing.Harness and related helpers within your test suite.
  • Guided Migration: Provides step-by-step instructions and recipes for rewriting tests to model Juju events and states accurately.
  • Use Case: You have a charm with many unit tests still using Harness. This Skill will guide you through systematically replacing them with state-transition tests, ensuring your charm's test suite remains functional and maintainable.

Quick Start

Run the provided script to find all remaining Harness usages in your tests.

Frequently Asked Questions about migrate-harness-tests-to-state-transition-test

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

FAQPage Schema
How do I migrate Juju charm tests from Harness to state-transition tests?

Migrate Juju charm tests from Harness by identifying ops.testing.Harness usages, defining explicit Juju states, and recreating assertions per Juju event to ensure compatibility with current ops releases and improve test reliability.

What are state-transition tests in Juju charm development?

State-transition tests in Juju charm development are a modern, event-driven testing approach that models Juju events and states accurately, replacing the deprecated ops.testing.Harness framework to maintain functional and maintainable test suites.

How do I find all Harness usages in my charm test suite?

Find all Harness usages in your charm test suite by running the provided detection script, which identifies ops.testing.Harness and related helper instances to guide systematic test replacement.

Does this migration process require a specific plan before rewriting tests?

Yes, the migration process requires adherence to mandatory preflight checks and a mandatory plan and ledger, ensuring structured rewriting and validation against existing repository tooling before finalizing state-transition tests.

Why should I replace ops.testing.Harness with state-transition tests?

Replace ops.testing.Harness with state-transition tests because Harness is deprecated, and modern state-transition tests ensure compatibility with current Juju releases while improving overall test reliability and maintainability.