perl-testing
Perl testing patterns using Test2::V0, Test::More, prove runner, mocking, Devel::Cover coverage, and TDD methodology.
Translation reviewedRead the original Chinese text
使用Test2::V0、Test::More、prove runner、模拟、Devel::Cover覆盖率和TDD方法的Perl测试模式。
Target: Software development & testing. Automatically collected · unverified.
Excerpt from the author’s documentation
Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.
Read the original Chinese text
Topics in the source
- Perl 测试模式
- 何时激活
- TDD 工作流程
- Test::More 基础
- 基本断言
- SKIP 和 TODO
- Test2::V0 现代框架
- 为什么选择 Test2?
使用 Test2::V0、Test::More、prove 和 TDD 方法论为 Perl 应用程序提供全面的测试策略。 编写新的 Perl 代码(遵循 TDD:红、绿、重构) 为 Perl 模块或应用程序设计测试套件 审查 Perl 测试覆盖率 设置 Perl 测试基础设施 将测试从 Test::More 迁移到 Test2::V0 调试失败的 Perl 测试 始终遵循 RED-GREEN-REFACTOR 循环。 标准的 Perl 测试模块 —— 广泛使用,随核心发行。 Test2::V0 是 Test::More 的现代替代品 —— 更丰富的断言、更好的诊断和可扩展性。 使用哈希/数组构建器进行卓越的深层比较 失败时提供更好的诊断输出 具有更清晰作用域的子测试 可通过 Test2::Tools::\ 插件扩展 与 Test::More 测试向后兼容 将可重用的助手放在 t/lib/TestHelper.pm 中,并通过 use lib 't/lib' 加载。通过 Exporter 导出工厂函数,例如 createtestdb()、createtempdir() 和 fixturepath()。 对于轻量级的模拟对象,使用 Test::MockObject 创建可注入的测试替身,使用 ->mock() 并验证调用 ->calledok()。 对数据库测试使用内存中的 SQLite,对 API 测试模拟 HTTP::Tiny。 遵循 TDD:在实现之前编写测试(红-绿-重构) 使用 Test2::V0:现代断言,更好的诊断 使用子测试:分组相关断言,隔离状态 模拟外部依赖:网络、数据库、文件系统 使用 prove -l:始终将 lib/ 包含在 @INC 中 清晰命名测试:'user login with invalid password fails' 测试边界情况:空字符串、undef、零、边界值 目标 80%+ 覆盖率:专注于业务逻辑路径 保持测试快速:模拟 I/O,使用内存数据库 不要测试实现:测试行为和输出,而非内部细节 不要在子测试之间共享状态:每个子测试都应是独立的 不要跳过 donetesting:确保所有计划的测试都已运行 不要过度模拟:仅模拟边界,而非被测试的代码 不要在新项目中使用 Test::More:首选 Test2::V0 不要忽略测试失败:所有测试必须在合并前通过 不要测试 CPAN 模块:相信库能正常工作 不要编写脆弱的测试:避免过度具体的字符串匹配 | 任务 | 命令 / 模式 | |---|---| | 运行所有测试 | prove -lr t/ | | 详细运行单个测试 | prove -lv t/unit/user.t | | 并行测试运行 | prove -lr -j8 t/ | | 覆盖率报告 | cover -t
This is an excerpt. Refer to the complete source and its current requirements.
- Source repository
- affaan-m/ECC
- Source file
- docs/zh-CN/skills/perl-testing/SKILL.md
- Fixed revision
- d2ef2680594f9a17526a6e1a2e18b3d242c5d17b
Requirements
- Only the author’s Skill metadata is included. Read the full instructions to check dependencies, licensing and conditions of use.
A small first task
先阅读原作者说明,再决定是否在自己的 AI 工具中使用。
Instructions for your AI tool
- Claude Desktop: resource-specific guide not available yet
- Claude Code: resource-specific guide not available yet
- Cursor: resource-specific guide not available yet
- Codex: resource-specific guide not available yet
Author documentation is not live verification by this site. Without evidence, we do not mark a resource as compatible, safe or free.
Sources and evidence
This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.
Author: affaan-m/ECC · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-09T15:01:42.508Z.
Categories are inferred from names, descriptions and paths. They do not establish compatibility.
License and attribution
MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.
Original license ↗Synchronization, copying and user-reported success do not mark a resource as runtime-tested.
Limitations and notes
- Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.