[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73F54MT7XP0358A0X8MAQDQ":3,"skill-same:01M73F54MT7XP0358A0X8MAQDQ":49},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":30,"ownerHtmlUrl":31,"ownerBlogUrl":32,"ownerDescription":33,"updatedAt":34,"install":35,"resources":48},"01M73F54MT7XP0358A0X8MAQDQ","perl-testing",null,"Perl testing patterns using Test2::V0, Test::More, prove runner, mocking, coverage with Devel::Cover, and TDD methodology.","Horonomos-laps\u002FYana-AI","Horonomos-laps","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F355299122?v=4","01M76B3QPXE88ET2SQPDPVATZT"," Horonomos-laps","01M72ZQRJPCYPSSWT4D00VJR2A",13,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fperl-testing\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: perl-testing\ndescription: Perl testing patterns using Test2::V0, Test::More, prove runner, mocking, coverage with Devel::Cover, and TDD methodology.\norigin: ECC\n---\n\n# Perl Testing Patterns\n\nComprehensive testing strategies for Perl applications using Test2::V0, Test::More, prove, and TDD methodology.\n\n## When to Activate\n\n- Writing new Perl code (follow TDD: red, green, refactor)\n- Designing test suites for Perl modules or applications\n- Reviewing Perl test coverage\n- Setting up Perl testing infrastructure\n- Migrating tests from Test::More to Test2::V0\n- Debugging failing Perl tests\n\n## TDD Workflow\n\nAlways follow the RED-GREEN-REFACTOR cycle.\n\n```perl\n# Step 1: RED — Write a failing test\n# t\u002Funit\u002Fcalculator.t\nuse v5.36;\nuse Test2::V0;\n\nuse lib 'lib';\nuse Calculator;\n\nsubtest 'addition' => sub {\n    my $calc = Calculator->new;\n    is($calc->add(2, 3), 5, 'adds two numbers');\n    is($calc->add(-1, 1), 0, 'handles negatives');\n};\n\ndone_testing;\n\n# Step 2: GREEN — Write minimal implementation\n# lib\u002FCalculator.pm\npackage Calculator;\nuse v5.36;\nuse Moo;\n\nsub add($self, $a, $b) {\n    return $a + $b;\n}\n\n1;\n\n# Step 3: REFACTOR — Improve while tests stay green\n# Run: prove -lv t\u002Funit\u002Fcalculator.t\n```\n\n## Test::More Fundamentals\n\nThe standard Perl testing module — widely used, ships with core.\n\n### Basic Assertions\n\n```perl\nuse v5.36;\nuse Test::More;\n\n# Plan upfront or use done_testing\n# plan tests => 5;  # Fixed plan (optional)\n\n# Equality\nis($result, 42, 'returns correct value');\nisnt($result, 0, 'not zero');\n\n# Boolean\nok($user->is_active, 'user is active');\nok(!$user->is_banned, 'user is not banned');\n\n# Deep comparison\nis_deeply(\n    $got,\n    { name => 'Alice', roles => ['admin'] },\n    'returns expected structure'\n);\n\n# Pattern matching\nlike($error, qr\u002Fnot found\u002Fi, 'error mentions not found');\nunlike($output, qr\u002Fpassword\u002F, 'output hides password');\n\n# Type check\nisa_ok($obj, 'MyApp::User');\ncan_ok($obj, 'save', 'delete');\n\ndone_testing;\n```\n\n### SKIP and TODO\n\n```perl\nuse v5.36;\nuse Test::More;\n\n# Skip tests conditionally\nSKIP: {\n    skip 'No database configured', 2 unless $ENV{TEST_DB};\n\n    my $db = connect_db();\n    ok($db->ping, 'database is reachable');\n    is($db->version, '15', 'correct PostgreSQL version');\n}\n\n# Mark expected failures\nTODO: {\n    local $TODO = 'Caching not yet implemented';\n    is($cache->get('key'), 'value', 'cache returns value');\n}\n\ndone_testing;\n```\n\n## Test2::V0 Modern Framework\n\nTest2::V0 is the modern replacement for Test::More — richer assertions, better diagnostics, and extensible.\n\n### Why Test2?\n\n- Superior deep comparison with hash\u002Farray builders\n- Better diagnostic output on failures\n- Subtests with cleaner scoping\n- Extensible via Test2::Tools::* plugins\n- Backward-compatible with Test::More tests\n\n### Deep Comparison with Builders\n\n```perl\nuse v5.36;\nuse Test2::V0;\n\n# Hash builder — check partial structure\nis(\n    $user->to_hash,\n    hash {\n        field name  => 'Alice';\n        field email => match(qr\u002F\\@example\\.com$\u002F);\n        field age   => validator(sub { $_ >= 18 });\n        # Ignore other fields\n        etc();\n    },\n    'user has expected fields'\n);\n\n# Array builder\nis(\n    $result,\n    array {\n        item 'first';\n        item match(qr\u002F^second\u002F);\n        item DNE();  # Does Not Exist — verify no extra items\n    },\n    'result matches expected list'\n);\n\n# Bag — order-independent comparison\nis(\n    $tags,\n    bag {\n        item 'perl';\n        item 'testing';\n        item 'tdd';\n    },\n    'has all required tags regardless of order'\n);\n```\n\n### Subtests\n\n```perl\nuse v5.36;\nuse Test2::V0;\n\nsubtest 'User creation' => sub {\n    my $user = User->new(name => 'Alice', email => 'alice@example.com');\n    ok($user, 'user object created');\n    is($user->name, 'Alice', 'name is set');\n    is($user->email, 'alice@example.com', 'email is set');\n};\n\nsubtest 'User validation' => sub {\n    my $warnings = warns {\n        User->new(name => '', email => 'bad');\n    };\n    ok($warnings, 'warns on invalid data');\n};\n\ndone_testing;\n```\n\n### Exception Testing with Test2\n\n```perl\nuse v5.36;\nuse Test2::V0;\n\n# Test that code dies\nlike(\n    dies { divide(10, 0) },\n    qr\u002FDivision by zero\u002F,\n    'dies on division by zero'\n);\n\n# Test that code lives\nok(lives { divide(10, 2) }, 'division succeeds') or note($@);\n\n# Combined pattern\nsubtest 'error handling' => sub {\n    ok(lives { parse_config('valid.json') }, 'valid config parses');\n    like(\n        dies { parse_config('missing.json') },\n        qr\u002FCannot open\u002F,\n        'missing file dies with message'\n    );\n};\n\ndone_testing;\n```\n\n## Test Organization and prove\n\n### Directory Structure\n\n```text\nt\u002F\n├── 00-load.t              # Verify modules compile\n├── 01-basic.t             # Core functionality\n├── unit\u002F\n│   ├── config.t           # Unit tests by module\n│   ├── user.t\n│   └── util.t\n├── integration\u002F\n│   ├── database.t\n│   └── api.t\n├── lib\u002F\n│   └── TestHelper.pm      # Shared test utilities\n└── fixtures\u002F\n    ├── config.json        # Test data files\n    └── users.csv\n```\n\n### prove Commands\n\n```bash\n# Run all tests\nprove -l t\u002F\n\n# Verbose output\nprove -lv t\u002F\n\n# Run specific test\nprove -lv t\u002Funit\u002Fuser.t\n\n# Recursive search\nprove -lr t\u002F\n\n# Parallel execution (8 jobs)\nprove -lr -j8 t\u002F\n\n# Run only failing tests from last run\nprove -l --state=failed t\u002F\n\n# Colored output with timer\nprove -l --color --timer t\u002F\n\n# TAP output for CI\nprove -l --formatter TAP::Formatter::JUnit t\u002F > results.xml\n```\n\n### .proverc Configuration\n\n```text\n-l\n--color\n--timer\n-r\n-j4\n--state=save\n```\n\n## Fixtures and Setup\u002FTeardown\n\n### Subtest Isolation\n\n```perl\nuse v5.36;\nuse Test2::V0;\nuse File::Temp qw(tempdir);\nuse Path::Tiny;\n\nsubtest 'file processing' => sub {\n    # Setup\n    my $dir = tempdir(CLEANUP => 1);\n    my $file = path($dir, 'input.txt');\n    $file->spew_utf8(\"line1\\nline2\\nline3\\n\");\n\n    # Test\n    my $result = process_file(\"$file\");\n    is($result->{line_count}, 3, 'counts lines');\n\n    # Teardown happens automatically (CLEANUP => 1)\n};\n```\n\n### Shared Test Helpers\n\nPlace reusable helpers in `t\u002Flib\u002FTestHelper.pm` and load with `use lib 't\u002Flib'`. Export factory functions like `create_test_db()`, `create_temp_dir()`, and `fixture_path()` via `Exporter`.\n\n## Mocking\n\n### Test::MockModule\n\n```perl\nuse v5.36;\nuse Test2::V0;\nuse Test::MockModule;\n\nsubtest 'mock external API' => sub {\n    my $mock = Test::MockModule->new('MyApp::API');\n\n    # Good: Mock returns controlled data\n    $mock->mock(fetch_user => sub ($self, $id) {\n        return { id => $id, name => 'Mock User', email => 'mock@test.com' };\n    });\n\n    my $api = MyApp::API->new;\n    my $user = $api->fetch_user(42);\n    is($user->{name}, 'Mock User', 'returns mocked user');\n\n    # Verify call count\n    my $call_count = 0;\n    $mock->mock(fetch_user => sub { $call_count++; return {} });\n    $api->fetch_user(1);\n    $api->fetch_user(2);\n    is($call_count, 2, 'fetch_user called twice');\n\n    # Mock is automatically restored when $mock goes out of scope\n};\n\n# Bad: Monkey-patching without restoration\n# *MyApp::API::fetch_user = sub { ... };  # NEVER — leaks across tests\n```\n\nFor lightweight mock objects, use `Test::MockObject` to create injectable test doubles with `->mock()` and verify calls with `->called_ok()`.\n\n## Coverage with Devel::Cover\n\n### Running Coverage\n\n```bash\n# Basic coverage report\ncover -test\n\n# Or step by step\nperl -MDevel::Cover -Ilib t\u002Funit\u002Fuser.t\ncover\n\n# HTML report\ncover -report html\nopen cover_db\u002Fcoverage.html\n\n# Specific thresholds\ncover -test -report text | grep 'Total'\n\n# CI-friendly: fail under threshold\ncover -test && cover -report text -select '^lib\u002F' \\\n  | perl -ne 'if (\u002FTotal.*?(\\d+\\.\\d+)\u002F) { exit 1 if $1 \u003C 80 }'\n```\n\n### Integration Testing\n\nUse in-memory SQLite for database tests, mock HTTP::Tiny for API tests.\n\n```perl\nuse v5.36;\nuse Test2::V0;\nuse DBI;\n\nsubtest 'database integration' => sub {\n    my $dbh = DBI->connect('dbi:SQLite:dbname=:memory:', '', '', {\n        RaiseError => 1,\n    });\n    $dbh->do('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)');\n\n    $dbh->prepare('INSERT INTO users (name) VALUES (?)')->execute('Alice');\n    my $row = $dbh->selectrow_hashref('SELECT * FROM users WHERE name = ?', undef, 'Alice');\n    is($row->{name}, 'Alice', 'inserted and retrieved user');\n};\n\ndone_testing;\n```\n\n## Best Practices\n\n### DO\n\n- **Follow TDD**: Write tests before implementation (red-green-refactor)\n- **Use Test2::V0**: Modern assertions, better diagnostics\n- **Use subtests**: Group related assertions, isolate state\n- **Mock external dependencies**: Network, database, file system\n- **Use `prove -l`**: Always include lib\u002F in `@INC`\n- **Name tests clearly**: `'user login with invalid password fails'`\n- **Test edge cases**: Empty strings, undef, zero, boundary values\n- **Aim for 80%+ coverage**: Focus on business logic paths\n- **Keep tests fast**: Mock I\u002FO, use in-memory databases\n\n### DON'T\n\n- **Don't test implementation**: Test behavior and output, not internals\n- **Don't share state between subtests**: Each subtest should be independent\n- **Don't skip `done_testing`**: Ensures all planned tests ran\n- **Don't over-mock**: Mock boundaries only, not the code under test\n- **Don't use `Test::More` for new projects**: Prefer Test2::V0\n- **Don't ignore test failures**: All tests must pass before merge\n- **Don't test CPAN modules**: Trust libraries to work correctly\n- **Don't write brittle tests**: Avoid over-specific string matching\n\n## Quick Reference\n\n| Task | Command \u002F Pattern |\n|---|---|\n| Run all tests | `prove -lr t\u002F` |\n| Run one test verbose | `prove -lv t\u002Funit\u002Fuser.t` |\n| Parallel test run | `prove -lr -j8 t\u002F` |\n| Coverage report | `cover -test && cover -report html` |\n| Test equality | `is($got, $expected, 'label')` |\n| Deep comparison | `is($got, hash { field k => 'v'; etc() }, 'label')` |\n| Test exception | `like(dies { ... }, qr\u002Fmsg\u002F, 'label')` |\n| Test no exception | `ok(lives { ... }, 'label')` |\n| Mock a method | `Test::MockModule->new('Pkg')->mock(m => sub { ... })` |\n| Skip tests | `SKIP: { skip 'reason', $count unless $cond; ... }` |\n| TODO tests | `TODO: { local $TODO = 'reason'; ... }` |\n\n## Common Pitfalls\n\n### Forgetting `done_testing`\n\n```perl\n# Bad: Test file runs but doesn't verify all tests executed\nuse Test2::V0;\nis(1, 1, 'works');\n# Missing done_testing — silent bugs if test code is skipped\n\n# Good: Always end with done_testing\nuse Test2::V0;\nis(1, 1, 'works');\ndone_testing;\n```\n\n### Missing `-l` Flag\n\n```bash\n# Bad: Modules in lib\u002F not found\nprove t\u002Funit\u002Fuser.t\n# Can't locate MyApp\u002FUser.pm in @INC\n\n# Good: Include lib\u002F in @INC\nprove -l t\u002Funit\u002Fuser.t\n```\n\n### Over-Mocking\n\nMock the *dependency*, not the code under test. If your test only verifies that a mock returns what you told it to, it tests nothing.\n\n### Test Pollution\n\nUse `my` variables inside subtests — never `our` — to prevent state leaking between tests.\n\n**Remember**: Tests are your safety net. Keep them fast, focused, and independent. Use Test2::V0 for new projects, prove for running, and Devel::Cover for accountability.\n","# Perl Testing Patterns\n\nComprehensive testing strategies for Perl applications using Test2::V0, Test::More, prove, and TDD methodology.\n\n## When to Activate\n\n- Writing new Perl code (follow TDD: red, green, refactor)\n- Designing test suites for Perl modules or applications\n- Reviewing Perl test coverage\n- Setting up Perl testing infrastructure\n- Migrating tests from Test::More to Test2::V0\n- Debugging failing Perl tests\n\n## TDD Workflow\n\nAlways follow the RED-GREEN-REFACTOR cycle.\n\n```perl\n# Step 1: RED — Write a failing test\n# t\u002Funit\u002Fcalculator.t\nuse v5.36;\nuse Test2::V0;\n\nuse lib 'lib';\nuse Calculator;\n\nsubtest 'addition' => sub {\n    my $calc = Calculator->new;\n    is($calc->add(2, 3), 5, 'adds two numbers');\n    is($calc->add(-1, 1), 0, 'handles negatives');\n};\n\ndone_testing;\n\n# Step 2: GREEN — Write minimal implementation\n# lib\u002FCalculator.pm\npackage Calculator;\nuse v5.36;\nuse Moo;\n\nsub add($self, $a, $b) {\n    return $a + $b;\n}\n\n1;\n\n# Step 3: REFACTOR — Improve while tests stay green\n# Run: prove -lv t\u002Funit\u002Fcalculator.t\n```\n\n## Test::More Fundamentals\n\nThe standard Perl testing module — widely used, ships with core.\n\n### Basic Assertions\n\n```perl\nuse v5.36;\nuse Test::More;\n\n# Plan upfront or use done_testing\n# plan tests => 5;  # Fixed plan (optional)\n\n# Equality\nis($result, 42, 'returns correct value');\nisnt($result, 0, 'not zero');\n\n# Boolean\nok($user->is_active, 'user is active');\nok(!$user->is_banned, 'user is not banned');\n\n# Deep comparison\nis_deeply(\n    $got,\n    { name => 'Alice', roles => ['admin'] },\n    'returns expected structure'\n);\n\n# Pattern matching\nlike($error, qr\u002Fnot found\u002Fi, 'error mentions not found');\nunlike($output, qr\u002Fpassword\u002F, 'output hides password');\n\n# Type check\nisa_ok($obj, 'MyApp::User');\ncan_ok($obj, 'save', 'delete');\n\ndone_testing;\n```\n\n### SKIP and TODO\n\n```perl\nuse v5.36;\nuse Test::More;\n\n# Skip tests conditionally\nSKIP: {\n    skip 'No database configured', 2 unless $ENV{TEST_DB};\n\n    my $db = connect_db();\n    ok($db->ping, 'database is reachable');\n    is($db->version, '15', 'correct PostgreSQL version');\n}\n\n# Mark expected failures\nTODO: {\n    local $TODO = 'Caching not yet implemented';\n    is($cache->get('key'), 'value', 'cache returns value');\n}\n\ndone_testing;\n```\n\n## Test2::V0 Modern Framework\n\nTest2::V0 is the modern replacement for Test::More — richer assertions, better diagnostics, and extensible.\n\n### Why Test2?\n\n- Superior deep comparison with hash\u002Farray builders\n- Better diagnostic output on failures\n- Subtests with cleaner scoping\n- Extensible via Test2::Tools::* plugins\n- Backward-compatible with Test::More tests\n\n### Deep Comparison with Builders\n\n```perl\nuse v5.36;\nuse Test2::V0;\n\n# Hash builder — check partial structure\nis(\n    $user->to_hash,\n    hash {\n        field name  => 'Alice';\n        field email => match(qr\u002F\\@example\\.com$\u002F);\n        field age   => validator(sub { $_ >= 18 });\n        # Ignore other fields\n        etc();\n    },\n    'user has expected fields'\n);\n\n# Array builder\nis(\n    $result,\n    array {\n        item 'first';\n        item match(qr\u002F^second\u002F);\n        item DNE();  # Does Not Exist — verify no extra items\n    },\n    'result matches expected list'\n);\n\n# Bag — order-independent comparison\nis(\n    $tags,\n    bag {\n        item 'perl';\n        item 'testing';\n        item 'tdd';\n    },\n    'has all required tags regardless of order'\n);\n```\n\n### Subtests\n\n```perl\nuse v5.36;\nuse Test2::V0;\n\nsubtest 'User creation' => sub {\n    my $user = User->new(name => 'Alice', email => 'alice@example.com');\n    ok($user, 'user object created');\n    is($user->name, 'Alice', 'name is set');\n    is($user->email, 'alice@example.com', 'email is set');\n};\n\nsubtest 'User validation' => sub {\n    my $warnings = warns {\n        User->new(name => '', email => 'bad');\n    };\n    ok($warnings, 'warns on invalid data');\n};\n\ndone_testing;\n```\n\n### Exception Testing with Test2\n\n```perl\nuse v5.36;\nuse Test2::V0;\n\n# Test that code dies\nlike(\n    dies { divide(10, 0) },\n    qr\u002FDivision by zero\u002F,\n    'dies on division by zero'\n);\n\n# Test that code lives\nok(lives { divide(10, 2) }, 'division succeeds') or note($@);\n\n# Combined pattern\nsubtest 'error handling' => sub {\n    ok(lives { parse_config('valid.json') }, 'valid config parses');\n    like(\n        dies { parse_config('missing.json') },\n        qr\u002FCannot open\u002F,\n        'missing file dies with message'\n    );\n};\n\ndone_testing;\n```\n\n## Test Organization and prove\n\n### Directory Structure\n\n```text\nt\u002F\n├── 00-load.t              # Verify modules compile\n├── 01-basic.t             # Core functionality\n├── unit\u002F\n│   ├── config.t           # Unit tests by module\n│   ├── user.t\n│   └── util.t\n├── integration\u002F\n│   ├── database.t\n│   └── api.t\n├── lib\u002F\n│   └── TestHelper.pm      # Shared test utilities\n└── fixtures\u002F\n    ├── config.json        # Test data files\n    └── users.csv\n```\n\n### prove Commands\n\n```bash\n# Run all tests\nprove -l t\u002F\n\n# Verbose output\nprove -lv t\u002F\n\n# Run specific test\nprove -lv t\u002Funit\u002Fuser.t\n\n# Recursive search\nprove -lr t\u002F\n\n# Parallel execution (8 jobs)\nprove -lr -j8 t\u002F\n\n# Run only failing tests from last run\nprove -l --state=failed t\u002F\n\n# Colored output with timer\nprove -l --color --timer t\u002F\n\n# TAP output for CI\nprove -l --formatter TAP::Formatter::JUnit t\u002F > results.xml\n```\n\n### .proverc Configuration\n\n```text\n-l\n--color\n--timer\n-r\n-j4\n--state=save\n```\n\n## Fixtures and Setup\u002FTeardown\n\n### Subtest Isolation\n\n```perl\nuse v5.36;\nuse Test2::V0;\nuse File::Temp qw(tempdir);\nuse Path::Tiny;\n\nsubtest 'file processing' => sub {\n    # Setup\n    my $dir = tempdir(CLEANUP => 1);\n    my $file = path($dir, 'input.txt');\n    $file->spew_utf8(\"line1\\nline2\\nline3\\n\");\n\n    # Test\n    my $result = process_file(\"$file\");\n    is($result->{line_count}, 3, 'counts lines');\n\n    # Teardown happens automatically (CLEANUP => 1)\n};\n```\n\n### Shared Test Helpers\n\nPlace reusable helpers in `t\u002Flib\u002FTestHelper.pm` and load with `use lib 't\u002Flib'`. Export factory functions like `create_test_db()`, `create_temp_dir()`, and `fixture_path()` via `Exporter`.\n\n## Mocking\n\n### Test::MockModule\n\n```perl\nuse v5.36;\nuse Test2::V0;\nuse Test::MockModule;\n\nsubtest 'mock external API' => sub {\n    my $mock = Test::MockModule->new('MyApp::API');\n\n    # Good: Mock returns controlled data\n    $mock->mock(fetch_user => sub ($self, $id) {\n        return { id => $id, name => 'Mock User', email => 'mock@test.com' };\n    });\n\n    my $api = MyApp::API->new;\n    my $user = $api->fetch_user(42);\n    is($user->{name}, 'Mock User', 'returns mocked user');\n\n    # Verify call count\n    my $call_count = 0;\n    $mock->mock(fetch_user => sub { $call_count++; return {} });\n    $api->fetch_user(1);\n    $api->fetch_user(2);\n    is($call_count, 2, 'fetch_user called twice');\n\n    # Mock is automatically restored when $mock goes out of scope\n};\n\n# Bad: Monkey-patching without restoration\n# *MyApp::API::fetch_user = sub { ... };  # NEVER — leaks across tests\n```\n\nFor lightweight mock objects, use `Test::MockObject` to create injectable test doubles with `->mock()` and verify calls with `->called_ok()`.\n\n## Coverage with Devel::Cover\n\n### Running Coverage\n\n```bash\n# Basic coverage report\ncover -test\n\n# Or step by step\nperl -MDevel::Cover -Ilib t\u002Funit\u002Fuser.t\ncover\n\n# HTML report\ncover -report html\nopen cover_db\u002Fcoverage.html\n\n# Specific thresholds\ncover -test -report text | grep 'Total'\n\n# CI-friendly: fail under threshold\ncover -test && cover -report text -select '^lib\u002F' \\\n  | perl -ne 'if (\u002FTotal.*?(\\d+\\.\\d+)\u002F) { exit 1 if $1 \u003C 80 }'\n```\n\n### Integration Testing\n\nUse in-memory SQLite for database tests, mock HTTP::Tiny for API tests.\n\n```perl\nuse v5.36;\nuse Test2::V0;\nuse DBI;\n\nsubtest 'database integration' => sub {\n    my $dbh = DBI->connect('dbi:SQLite:dbname=:memory:', '', '', {\n        RaiseError => 1,\n    });\n    $dbh->do('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)');\n\n    $dbh->prepare('INSERT INTO users (name) VALUES (?)')->execute('Alice');\n    my $row = $dbh->selectrow_hashref('SELECT * FROM users WHERE name = ?', undef, 'Alice');\n    is($row->{name}, 'Alice', 'inserted and retrieved user');\n};\n\ndone_testing;\n```\n\n## Best Practices\n\n### DO\n\n- **Follow TDD**: Write tests before implementation (red-green-refactor)\n- **Use Test2::V0**: Modern assertions, better diagnostics\n- **Use subtests**: Group related assertions, isolate state\n- **Mock external dependencies**: Network, database, file system\n- **Use `prove -l`**: Always include lib\u002F in `@INC`\n- **Name tests clearly**: `'user login with invalid password fails'`\n- **Test edge cases**: Empty strings, undef, zero, boundary values\n- **Aim for 80%+ coverage**: Focus on business logic paths\n- **Keep tests fast**: Mock I\u002FO, use in-memory databases\n\n### DON'T\n\n- **Don't test implementation**: Test behavior and output, not internals\n- **Don't share state between subtests**: Each subtest should be independent\n- **Don't skip `done_testing`**: Ensures all planned tests ran\n- **Don't over-mock**: Mock boundaries only, not the code under test\n- **Don't use `Test::More` for new projects**: Prefer Test2::V0\n- **Don't ignore test failures**: All tests must pass before merge\n- **Don't test CPAN modules**: Trust libraries to work correctly\n- **Don't write brittle tests**: Avoid over-specific string matching\n\n## Quick Reference\n\n| Task | Command \u002F Pattern |\n|---|---|\n| Run all tests | `prove -lr t\u002F` |\n| Run one test verbose | `prove -lv t\u002Funit\u002Fuser.t` |\n| Parallel test run | `prove -lr -j8 t\u002F` |\n| Coverage report | `cover -test && cover -report html` |\n| Test equality | `is($got, $expected, 'label')` |\n| Deep comparison | `is($got, hash { field k => 'v'; etc() }, 'label')` |\n| Test exception | `like(dies { ... }, qr\u002Fmsg\u002F, 'label')` |\n| Test no exception | `ok(lives { ... }, 'label')` |\n| Mock a method | `Test::MockModule->new('Pkg')->mock(m => sub { ... })` |\n| Skip tests | `SKIP: { skip 'reason', $count unless $cond; ... }` |\n| TODO tests | `TODO: { local $TODO = 'reason'; ... }` |\n\n## Common Pitfalls\n\n### Forgetting `done_testing`\n\n```perl\n# Bad: Test file runs but doesn't verify all tests executed\nuse Test2::V0;\nis(1, 1, 'works');\n# Missing done_testing — silent bugs if test code is skipped\n\n# Good: Always end with done_testing\nuse Test2::V0;\nis(1, 1, 'works');\ndone_testing;\n```\n\n### Missing `-l` Flag\n\n```bash\n# Bad: Modules in lib\u002F not found\nprove t\u002Funit\u002Fuser.t\n# Can't locate MyApp\u002FUser.pm in @INC\n\n# Good: Include lib\u002F in @INC\nprove -l t\u002Funit\u002Fuser.t\n```\n\n### Over-Mocking\n\nMock the *dependency*, not the code under test. If your test only verifies that a mock returns what you told it to, it tests nothing.\n\n### Test Pollution\n\nUse `my` variables inside subtests — never `our` — to prevent state leaking between tests.\n\n**Remember**: Tests are your safety net. Keep them fast, focused, and independent. Use Test2::V0 for new projects, prove for running, and Devel::Cover for accountability.\n",{"name":5,"origin":24,"description":7},"ECC","main","481dcd7dd2e288b9d627a2bd017db70e64e6c6fa","core\u002Fskills\u002Fperl-testing",1,"https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI","https:\u002F\u002Fyana.vutam.link\u002F","https:\u002F\u002Fgithub.com\u002FHoronomos-laps","https:\u002F\u002Fyana.vutam.link","An open-source governed runtime & execution environment for multi-agent AI systems.","2026-11-11 23:56:26",{"source":8,"skillName":5,"commands":36,"prompt":46,"zipAvailable":47},[37,40,43],{"tool":38,"command":39},"npx","npx skills add Horonomos-laps\u002FYana-AI --skill perl-testing",{"tool":41,"command":42},"bunx","bunx skills add Horonomos-laps\u002FYana-AI --skill perl-testing",{"tool":44,"command":45},"pnpm","pnpm dlx skills add Horonomos-laps\u002FYana-AI --skill perl-testing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fperl-testing\u002FSKILL.md",true,[],[50,58,65,73,81,89],{"skillNo":51,"name":52,"nameZh":6,"description":53,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":54,"licenseFileUrl":6,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":19},"01M735GKET5YVYKAY62W2P5YXB","openai--sentry--sentry","Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.","MIT","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fopenai--sentry--sentry\u002FSKILL.md",[],[],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":19},"01M73DCAP83T17HY7SMGK7MGFE","ito-basket-compare","Compare Itô prediction-market baskets against a user's knowledge base, portfolio notes, financial context, watchlist, or research thesis. Use for read-only basket comparison and gap analysis without investment advice or live trading.","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fito-basket-compare\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":69,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M734CYEMZFDR3KH6SW0JP8TD","implementing-network-traffic-baselining","Build network traffic baselines from NetFlow\u002FIPFIX data using Python pandas for statistical analysis, z-score anomaly detection, and hourly\u002Fdaily traffic pattern profiling","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":77,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M73ASZ6NJRJM44Z2P84NGQ3Q","detecting-evasion-techniques-in-endpoint-logs","Detects defense evasion techniques used by adversaries in endpoint logs including log tampering, timestomping, process injection, and security tool disabling. Use when investigating suspicious endpoint behavior, building detection rules for evasion tactics, or conducting threat hunting for stealthy adversary activity. Activates for requests involving evasion detection, defense evasion analysis, log tampering detection, or MITRE ATT&CK TA0005.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":85,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":19},"01M734AFNXD06Z78QRK0VKGT7Q","implementing-microsegmentation-with-guardicore","Implementing microsegmentation using Akamai Guardicore Segmentation to map application dependencies, create granular network policies, visualize east-west traffic flows, and enforce least-privilege communication between workloads across data centers and cloud.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":19},"01M736TK27QMCXK0DVCH25SJN5","ramdisk-tmpfs-patterns","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Framdisk-tmpfs-patterns\u002FSKILL.md",[],[]]