perl-testing

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

Updated Mar 25, 2026
One-click install
npx skills add https://github.com/Femad-6/my-skills --skill perl-testing-femad-6
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: perl-testing
Source: https://github.com/Femad-6/my-skills/tree/main/.github/skills/perl-testing
Command: npx skills add https://github.com/Femad-6/my-skills --skill perl-testing-femad-6

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing reliable Perl tests requires choosing the right framework, structuring test files, mocking dependencies, and measuring coverage, which is error-prone without established patterns. ## Core Features & Use Cases - Modern Test2::V0 Patterns: Deep comparison with hash/array/bag builders, subtests, and exception testing with dies/lives. - Test Runner & Coverage Workflows: prove commands for parallel runs and CI output, plus Devel::Cover reports with threshold checks. - Mocking & Fixtures: Test::MockModule and Test::MockObject usage, temp directories, in-memory SQLite integration tests, and shared test helpers. - Use Case: When adding a new Perl module, follow the red-green-refactor cycle to write a failing Test2::V0 test, implement the minimal code, then run prove -lv and cover -test to verify behavior and coverage. ## Quick Start Write a Test2::V0 test file for my Calculator module following TDD and show me the prove command to run it.

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 and run it with prove -lv t/your_test.t.

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

Test2::V0 is the modern replacement offering richer deep-comparison builders, better failure diagnostics, and cleaner subtest scoping. Test::More still works and ships with core Perl, but Test2::V0 is recommended for new projects.

How do I run Perl tests in parallel with prove?

Run prove with the -j flag followed by the job count, such as prove -lr -j8 t/, to execute tests across 8 parallel workers. Add --state=failed to rerun only previously failing tests.

How do I mock a Perl module method in tests?

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

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

This happens when prove runs without the -l flag, so modules in your lib/ directory are not added to @INC. Always run prove -l t/ or add -l to your .proverc configuration file.

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

Run cover -test to execute your suite under Devel::Cover, then cover -report html to generate a browsable report in cover_db/. You can parse the text report in CI to fail builds below a coverage threshold such as 80 percent.