perl-testing

Implements Perl test suites using Test2::V0, prove, mocking, and Devel::Cover coverage.

Updated Apr 18, 2026
One-click install
npx skills add https://github.com/JohnRebellion/.claude-public --skill perl-testing-johnrebellion
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: perl-testing
Source: https://github.com/JohnRebellion/.claude-public/tree/main/claude/skills/perl-testing
Command: npx skills add https://github.com/JohnRebellion/.claude-public --skill perl-testing-johnrebellion

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing reliable Perl tests requires choosing the right framework, structuring test files correctly, mocking external dependencies, and measuring coverage. This Skill provides proven patterns for Test2::V0, Test::More, prove, and TDD so Perl code ships with a trustworthy test safety net. ## Core Features & Use Cases - Modern Test2::V0 Assertions: Deep comparison with hash/array/bag builders, subtests, and exception testing via dies/lives. - Test Runner & Coverage Workflows: prove commands for parallel runs, failure-only reruns, and Devel::Cover reports with CI thresholds. - Mocking & Integration Patterns: Test::MockModule/Test::MockObject for external APIs, in-memory SQLite for database tests, and fixture management with temp directories. - Use Case: When migrating a legacy Test::More suite to Test2::V0, apply the builder-based deep comparisons and subtest isolation patterns to modernize tests without losing coverage. ## Quick Start Write a failing Test2::V0 test for my Calculator module and show me the minimal implementation to make it pass using the red-green-refactor cycle.

Frequently Asked Questions about perl-testing

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

FAQPage Schema
How do I write Perl tests with Test2::V0?▼

Use Test2::V0 with is() for equality, subtests for grouping, and hash/array builders for deep comparison. End every test file with done_testing to verify all planned tests executed.

Test2::V0 vs Test::More for Perl testing?▼

Test2::V0 offers richer deep-comparison builders, better failure diagnostics, and cleaner subtest scoping, while remaining backward-compatible with Test::More. Prefer Test2::V0 for new projects.

How do I run Perl tests with prove in parallel?▼

Run prove with the -j flag followed by the job count, such as prove -lr -j8 t/, to execute tests across eight parallel workers. Add -l to include lib/ in @INC and --state=failed to rerun only failures.

How do I mock a Perl module method in tests?▼

Use Test::MockModule to override methods on a target package, for example Test::MockModule->new('MyApp::API')->mock(fetch_user => sub { ... }). The mock restores automatically when the object goes out of scope.

Why does prove fail with 'Can't locate module in @INC'?▼

This happens when prove runs without the -l flag, so modules in lib/ are not added to @INC. Fix it by running prove -l t/ or adding -l to your .proverc configuration file.

How do I measure Perl test coverage with Devel::Cover?▼

Run cover -test to execute the suite under Devel::Cover, then cover -report html to generate a browsable report. In CI, parse the text report and fail the build when total coverage drops below your threshold.