TE

test-case-generator

Automates the generation of structured, CI-passing pytest suites for specific Python game modules.

Install

mkdir -p .claude/skills/test-case-generator && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/15339" && unzip -o skill.zip -d .claude/skills/test-case-generator && rm skill.zip

Installs to .claude/skills/test-case-generator

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Generates pytest test cases for new or modified robot-pokemon code. Use when a new feature, function, or module needs test coverage — produces correctly structured test classes with fixtures, assertions, and lint-clean code.
224 chars✓ has a “when” trigger
Intermediate

Key capabilities

  • Generate pytest test cases for new or modified robot-pokemon code
  • Map source files to corresponding test files following naming conventions
  • Create test classes with fixtures like GameState and MockRichLog
  • Write assertions based on expected game behavior
  • Ensure lint-clean code in generated tests

How it works

The skill takes input on files and functions to test, then generates pytest test cases. It follows specific naming conventions, includes fixtures, and writes assertions based on coverage-guided test writing principles, ensuring lint-clean code.

Inputs & outputs

You give it
File(s) to test, functions/classes, current coverage, and needed fixtures
You get back
Complete pytest test file or test class, ready to paste into tests/

When to use test-case-generator

  • Generating unit tests for new features
  • Increasing test coverage
  • Writing tests for game logic

About this skill

test-case-generator

Generates complete, CI-passing pytest test files for new robot-pokemon features.

Associated Agent

test-writer.agent.md

Instructions

1. Input

  • File(s) to test — e.g. pytemon/buildings.py
  • Functions/classes — which functions need coverage
  • Current coverage — run pytest --cov-report=term-missing and paste the MISS lines
  • Fixtures neededgs (GameState), output (MockRichLog), or custom

2. File Naming and Structure

pytemon/buildings.py  →  tests/test_buildings.py
pytemon/ui/battle_mixin.py  →  tests/test_battle_mixin.py
# tests/test_buildings.py
import pytest
from pytemon.buildings import enter_bike_shop, heal_all_pokemon
from tests.conftest import MockRichLog   # or define inline if not in conftest


class TestBikeShop:
    def test_gives_bicycle_on_first_visit(self, gs, output):
        enter_bike_shop(gs, output)
        assert gs.game_data["bag"].get("Bicycle") == 1
        assert gs.game_data["story_flags"].get("received_bicycle") is True

    def test_no_duplicate_bicycle_on_repeat(self, gs, output):
        enter_bike_shop(gs, output)
        enter_bike_shop(gs, output)
        assert gs.game_data["bag"].get("Bicycle") == 1   # still 1, not 2

    def test_repeat_visit_message(self, gs, output):
        enter_bike_shop(gs, output)
        output.lines.clear()
        enter_bike_shop(gs, output)
        assert any("already" in str(l).lower() or "enjoying" in str(l).lower()
                   for l in output.lines)

3. Coverage-Guided Test Writing

From --cov-report=term-missing output:

buildings.py    72%   MISS 45-52, 88, 101-110

Map line numbers back to uncovered branches:

  • Lines 45-52 → missing else branch of a condition → add a test hitting that branch
  • Line 88 → error path → add a test with invalid input
  • Lines 101-110 → repeat-visit block → add a "second call" test

4. Lint Rules to Follow in Test Code

# ❌ F841 — unused variable
result = some_function()    # result never used after

# ✅
some_function()

# ❌ RUF059 — unused unpacked slot
caught, shakes, messages = attempt_catch(...)   # messages unused

# ✅
caught, shakes, _ = attempt_catch(...)

# ❌ I001 — unsorted imports
import pytest
import os      # os should come before pytest

# ✅
import os
import pytest

5. Output

  • Complete test file or test class, ready to paste into tests/
  • Coverage statement ("these tests should bring coverage from X% to Y%")

Examples

Input: "Generate tests for exploration.py move_to_location — currently at 62% coverage."

Output skeleton:

class TestMoveToLocation:
    def test_valid_move_succeeds(self, gs, output):
        # arrange: player at Pallet Town which connects to Route 1
        assert gs.current_location == "Pallet Town"
        move_to_location(gs, "Route 1", output, lambda: None)
        assert gs.current_location == "Route 1"

    def test_invalid_destination_shows_error(self, gs, output):
        move_to_location(gs, "Nowhere", output, lambda: None)
        assert any("can't" in str(l).lower() or "not" in str(l).lower() for l in output.lines)

    def test_blocked_exit_respects_badge_gate(self, gs, output):
        gs.current_location = "Cerulean City"
        move_to_location(gs, "Route 24", output, lambda: None)
        assert gs.current_location == "Cerulean City"   # didn't move

Dependencies

  • tests/conftest.pygs and output fixtures, MockRichLog
  • pytest — test runner
  • pytemon/ — modules under test

Error Handling

  • Test imports fail: check for a circular import or missing __init__.py in tests/
  • Fixture not found: confirm fixtures are defined in conftest.py or the test file itself
  • Coverage not improving: re-run with --cov-report=term-missing and check if new tests hit the MISS lines

When not to use it

  • When testing code outside the robot-pokemon project
  • When the goal is not to increase test coverage or write unit tests
  • When test imports fail due to circular dependencies or missing __init__.py

Prerequisites

pytestpytemon/ (modules under test)tests/conftest.py (for fixtures)

Limitations

  • Specific to robot-pokemon code
  • Requires `pytest` as the test runner
  • Relies on `tests/conftest.py` for fixtures

How it compares

This skill generates structured, CI-passing pytest test files specifically for the robot-pokemon project, adhering to its conventions and coverage goals, unlike general test generation tools.

Compared to similar skills

test-case-generator side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
test-case-generator (this skill)04moNo flagsIntermediate
adk-engineer31moReviewAdvanced
unit-testing-test-generate24moReviewIntermediate
playwright-roll22moReviewAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

Search skills

Search the agent skills registry