migrate-harness-tests-to-state-transition-test
Migrate Harness Tests To State Transition Test
Overview
Guide charm maintainers through replacing deprecated Harness-based unit tests with deterministic state-transition tests that mirror how Juju actually fires events. Use this skill whenever a test still instantiates testing.Harness or chains multiple events inside one fixture.
When To Use
ops.testing.Harness(or Scenario Harness helpers) still appear in tests or fixtures.- Migration requires modeling relations, containers, secrets, or actions with
testing.State. - CI must stay green while Harness-only helpers (
add_relation,evaluate_status, etc.) are removed.
Preflight Checks
- Inspect
pyproject.toml(or requirements files) before touching code; ensureops[testing]is present in every dependency group that executes Scenario/state-transition tests. Remove legacyops-scenarioif it lingers. - Match the repo’s package manager: use
uv add --group unit ops[testing](and mirror across groups) when[tool.uv]oruv.lockexists; otherwise edit the appropriaterequirements.txt, Poetry group, etc. - After dependency edits, re-sync the exact groups you touched (
uv sync --group unit --group lint,poetry install, etc.) so the virtualenv contains Scenario Context. - Re-run the project’s bootstrap entrypoint (
uv sync,pip install -r requirements.txt,make setup, …) to align local + CI execution before rewriting tests.
More from canonical/copilot-collections
retrospective-artifacts
Builds and parses structured retrospective artifact folders for troubleshooting, incident review, and delivery retros. Use this skill when capturing session context, synthesizing external context (GitHub, Jira, Mattermost, logs), querying prior retrospectives, or preparing downstream inputs for OKB entries, postmortems, and agent/skills/instruction improvements.
8generate-agent
Generates Custom Agent files (.github/agents/*.agent.md) with persona-based configurations, specialized tool sets, and role-specific cognitive architectures. Use when the user requests a specialized role or perspective (Security Auditor, Documentation Writer, Release Engineer, etc.). Creates agents with defined identity, constrained tools, and thinking processes aligned to their role. Not for general capabilities—use generate-agent-skills for those.
3generate-repo-instructions
Generates the global repository constitution file (.github/copilot-instructions.md). Works for code repositories, documentation repositories, data repositories, and mixed repos. Performs LLM-driven deep repository analysis including docs, code patterns, build systems, documentation generators, and data schemas. Generates constitutional rules following context economics (under 1000 lines). Enforces positive constraints and no hardcoded secrets.
3generate-prompt
Generates reusable Prompt Template files (.github/prompts/*.prompt.md) with variable substitution for ad-hoc, high-frequency tasks. Use when the user needs quick, repeatable prompts for common operations (explain code, fix bug, add tests, refactor, document). Creates templates with handlebars variables, optimized context structure, and strict output constraints. Not for complex workflows (use skills) or persistent roles (use agents).
2documentation-build
Validates documentation builds successfully. Use when checking Sphinx/RTD build integrity or diagnosing build failures. Reports errors, warnings, and build configuration issues.
2documentation-review
Performs comprehensive documentation review including build validation, Diataxis analysis, structure audit, accuracy verification, and style compliance. Use when reviewing documentation changes or auditing documentation quality.
2