Unit test wizard
Skill mpagot/os-autoinst-distri-opensuse-skills/skills/unit-test-wizard
OSADO educated clankers
npx -y skills add mpagot/os-autoinst-distri-opensuse-skills --skill unit-test-wizardAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 4 stars4 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Writes and reviews OSADO Perl unit tests for library modules in lib/. Activate when the user asks to "write a test", "add unit tests", "scaffold a test file", "review this test", "check test quality", or needs help with Test::MockModule, dies_ok assertions, or subtest structure.
SKILL.md
4.3 KB, as published. Nobody here has run it
Tools
Script paths are relative to this skill's installed directory.
scripts/scaffold_test.pl-- Analyzes a.pmmodule and generates a complete.ttest file skeleton with proper imports, mocking, and subtests.scripts/review_test.pl-- Audits an existing.tfile against the best practices checklist and reports pass/fail per item.
Both scripts accept --repo, --json, --verbose, and --help.
Generate Mode
Use when the user asks to write tests for a library module.
- Identify the module path. Ask if unclear. Must be relative to the
OSADO repo root (e.g.,
lib/mypackage/module.pm). - Run the scaffold script:
This outputs a completeperl scripts/scaffold_test.pl --repo /path/to/osado lib/mypackage/module.pm.tfile to stdout. Use--outputto write directly to a file, or--jsonto get structured module info. - Review and customize the output. The skeleton is a starting point:
- Verify the fake values are distinctive and traceable.
- Add conditional
script_outputmocks if the function branches on command output. - Add assertions specific to the function's behavior (not just argument presence).
- Ensure optional args have their own subtests.
- Write the file to
t/NN_<module_name>.t(the script suggests the next available number). - Run the test:
prove -v -l -Ios-autoinst/ t/NN_<module_name>.t
Review Mode
Use when the user asks to review or audit an existing test file.
- Run the review script:
perl scripts/review_test.pl --repo /path/to/osado t/NN_foo.t - Present findings grouped as PASS/FAIL/WARN.
- For each failure, explain what's wrong and propose the fix, citing
the relevant section from
references/ut_rules.md. - Optionally re-run after applying fixes to confirm the check passes.
Key Patterns (quick reference)
File skeleton
use strict;
use warnings;
use Test::More;
use Test::Exception;
use Test::Warnings;
use Test::MockModule;
use Test::Mock::Time;
use List::Util qw(any none uniq all)
use mypackage::module_name;
subtest '[function_name]' => sub { ... };
done_testing;
The @calls capture pattern
subtest '[function_name]' => sub {
my @calls;
my $mock = Test::MockModule->new('mypackage::module_name', no_auto => 1);
$mock->redefine(assert_script_run => sub { push @calls, $_[0]; return; });
$mock->redefine(record_info => sub { note(join(' ', 'RECORD_INFO -->', @_)); });
function_name(arg1 => 'Agamemnon', arg2 => 'Mycenaeans');
note("\n --> " . join("\n --> ", @calls));
ok((any { /expected_pattern/ } @calls), 'Descriptive assertion message');
};
Mandatory arg testing
subtest '[function_name] missing arguments' => sub {
dies_ok { function_name(arg2 => 'X') } 'Die for missing argument arg1';
dies_ok { function_name(arg1 => 'X') } 'Die for missing argument arg2';
};
Rules
- Always use
no_auto => 1in Test::MockModule constructors. - Always use
redefine(), nevermock(). - Each subtest must be self-contained: own
@calls, own mocks, no shared state. - Always mock
record_info(redirect tonote). - Clean up
set_varwithundefat end of subtests. - Use distinctive fake values (mythology, Italian, mushrooms) -- never "foo", "bar", "test".
- Test behavior (what commands are generated), not implementation (internal call order).
- Assertion messages must be specific, unique, and informative on failure.
- Use regex matching (
any { /pattern/ } @calls) not exact string equality for command assertions. - Do NOT modify the library code -- this skill only creates/edits test files.
- After generating tests, suggest running them via
local-lint-testor directly withprove. </instructions>