with one click
generate-test-cases
// Use when source code changes under lib/jnpr/junos and the user wants unit tests created or updated for those changes.
// Use when source code changes under lib/jnpr/junos and the user wants unit tests created or updated for those changes.
| name | generate-test-cases |
| description | Use when source code changes under lib/jnpr/junos and the user wants unit tests created or updated for those changes. |
| allowed-tools | ["read_file","file_search","grep_search","run_in_terminal","apply_patch","get_errors","get_changed_files"] |
| context | fork |
Create or update unit tests for code changes under lib/jnpr/junos, matching the existing project style in tests/unit.
lib/jnpr/junos.tests/functional.Collect changed files and keep only paths under lib/jnpr/junos.
Preferred commands:
git diff --name-only -- lib/jnpr/junosgit diff --name-only --cached -- lib/jnpr/junosIf both are empty, ask for the exact files or compare against the upstream default branch:
git diff --name-only origin/master...HEAD -- lib/jnpr/junosUse these conventions first, then adjust to existing repository layout:
lib/jnpr/junos/device.py -> tests/unit/test_device.pylib/jnpr/junos/console.py -> tests/unit/test_console.pylib/jnpr/junos/facts/<name>.py -> tests/unit/facts/test_<name>.pylib/jnpr/junos/factory/<name>.py -> tests/unit/factory/test_<name>.pylib/jnpr/junos/utils/<name>.py -> tests/unit/utils/test_<name>.pyIf no matching test file exists, create one in the appropriate test subdirectory with naming test_<module>.py.
Read nearby tests and follow established conventions:
unittest/unittest2 style classes and test_* methods.unittest.mock (patch, MagicMock, mock_open).tests/unit/**/rpc-reply.Cover only behavior changed by the source diff.
For each changed behavior, include positive and negative paths when applicable:
Avoid brittle assertions on internal private state unless that is the public contract used across this repo.
Install required dependencies before executing tests:
python3 -m pip install ntc_templates==1.4.1 textfsm==0.4.1 python3 -m pip install -r requirements.txtpython3 -m pip install nose2 junos-ezncRun generated/updated testcase modules first (targeted validation), for example:
nose2 -vvv tests.unit.facts.test_<name> --plugin nose2.plugins.junitxml --junit-xmlnose2 -vvv tests.unit.test_<module> --plugin nose2.plugins.junitxml --junit-xmlOnly after targeted tests pass, optionally run the broader unit suite:
nose2 -vvv tests.unit --plugin nose2.plugins.junitxml --junit-xmlSummarize:
Include the generated testcase execution output in verbose format from nose2 -vvv.
At minimum, include:
... ok / ... FAIL / ... ERROR)Ran X tests in Ys and final status)When this skill is invoked, the final response must include:
nose2 -vvv.