add-project-test
Add or convert typed pytest tests in this hardware automation project. Use when asked to create unit, software-integration, or physical-hardware tests; add pytest markers or fixtures; create YAML-driv
SKILL.mdskills/add-project-test/SKILL.md
GitHubAdd Project Test
Create a focused test in the correct layer while keeping ordinary quality gates independent of physical hardware.
Inspect and classify
- Read
AGENTS.mdcompletely and follow its approval and verification rules. - Inspect the behavior under test, nearby tests, fixtures, markers, fakes, and public APIs.
- Classify the test before choosing its location:
- place isolated behavior using fakes in
tests/unit; - place multi-component framework composition without network I/O in
tests/integration; - place tests requiring a real stand in
tests/hardware.
- place isolated behavior using fakes in
- Preserve existing markers, fixtures, cleanup, mocks, and assertions when converting a test.
- If production behavior must change, propose and implement that change first; update tests only after the user approves the production code.
Design and review
- Fully type test functions, fixtures, fakes, and test models.
- Keep unit tests free of network and physical equipment.
- Use fakes in integration tests; never open real SSH connections there.
- Make hardware tests consume
TestStandlogical roles and device domain APIs, never physical IDs or direct SSH commands. - Require
--standonly for hardware tests. - Use registered pytest markers and preserve
--strict-markerscompatibility. - Use
yieldwithtry/finallyfor fixtures that allocate resources or change device state. - When a hardware-test group needs shared behavior or fixtures, place a local
base.pyin that group's directory and inherit its custom base class fromtests.hardware.base.BaseTest. A custom base class may define typed class-method fixtures with@pytest.fixture(scope="class")above@classmethod; useclsinstead of an instanceselfparameter, resolve devices from the injectedTestStandby logical role, and never keep mutable runtime state on the class. - Import the group-specific base in test modules under the common local name
BaseTest, for examplefrom tests.hardware.recovery.base import RecoveryBaseTest as BaseTest. - Show complete representative test code and list every file to create or modify.
- Request explicit approval before modifying files.
YAML-driven cases
Use YAML parametrization when cases are declarative scenario data:
- Store scenario data under
configs/, never inventory or settings. - Define typed Pydantic case and collection models close to the target test.
- Use
YamlConfigSourceand@yaml_parametrizefromyaml-test-params. - Rely on the automatically loaded plugin; do not add
pytest_generate_testswithout a genuine integration need. - Give cases stable, readable
test_nameIDs.
Implement and verify
- Modify only the approved tests, fixtures, models, configs, and documentation.
- Run the narrowest relevant test first; use
-vvfor YAML-parametrized cases. - Never run hardware tests without explicit permission and a ready physical stand.
- Stage the intended changes and run
./scripts/ci.sh. - Report the test layer, collected case count when relevant, and verification results.