scenario-tests

Drive Juju charm state transitions with ops.testing Scenario for unit tests.

1|Updated Feb 8, 2026
One-click install
npx skills add https://github.com/tonyandrewmeyer/cantrip --skill scenario-tests
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: scenario-tests
Source: https://github.com/tonyandrewmeyer/cantrip/tree/main/src/cantrip/skills/scenario-tests
Command: npx skills add https://github.com/tonyandrewmeyer/cantrip --skill scenario-tests

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Authoring unit tests for Juju charms can be error-prone and time-consuming without a structured testing framework.

Core Features & Use Cases

  • State-transition tests using ops.testing Scenario to drive charm behavior.
  • Clear separation of Context, State, and events for deterministic testing.
  • Guidance for testing common flows such as start, relation_joined, config_changed, and pebble_ready in isolation.

Quick Start

Create tests under tests/unit and use Scenario's Context, State, and on.* events to drive state transitions.

Frequently Asked Questions about scenario-tests

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

FAQPage Schema
How do I write unit tests for Juju charms without deploying to a live environment?

Scenario testing separates Context, State, and events to validate charm behavior across events like start, relation_joined, config_changed, and pebble_ready. This structured approach prevents errors and saves time when authoring unit tests for Juju charms.

What is the best way to test Pebble interactions in a Juju charm?

The best way to test Pebble interactions is using Scenario with ops.testing to drive state transitions. This allows you to validate pebble_ready events and Pebble behavior deterministically without a live Juju deployment.

Can I use pytest with ops.testing to verify Juju charm events?

Using pytest with ops.testing and Scenario allows you to verify Juju charm events by driving state transitions. This validates unit behavior across events such as start, relation_joined, and update_status without a live deployment.

How do I test config_changed and relation_joined events in isolation for my charm?

To test config_changed and relation_joined events in isolation, use Scenario with ops.testing to drive state transitions. This allows deterministic validation of charm unit behavior across these events without a live environment.

Does Scenario testing require a live Juju environment to validate charm behavior?

Scenario enables reliable Juju charm unit testing without a live deployment. By driving state transitions with ops.testing, it validates unit behavior across events such as start, config_changed, and update_status.

Why should I use Scenario for charm unit testing instead of manual testing approaches?

Using Scenario for charm unit testing avoids the error-prone nature of manual approaches. It provides clear separation of Context, State, and events, driving state transitions with ops.testing to validate behavior deterministically.