Claude Code assert-specific-error-in-tests skill for exact Rust error assertions
Assert the precise error variant and useful fields so unrelated failures cannot satisfy a negative test.
中文Install in Claude Code
A Claude Code project with Rust tests. Have the error contract and test inputs available.
- Review `.claude/skills/assert-specific-error-in-tests/SKILL.md` and its requirements at the pinned GitHub commit.
- Create `.claude/skills/assert-specific-error-in-tests/` in your project and save the reviewed file as `.claude/skills/assert-specific-error-in-tests/SKILL.md`.
- Start Claude Code from that project's root, then select `/assert-specific-error-in-tests` in the slash menu.
Example task
Invoke /assert-specific-error-in-tests and write a failure assertion from this fictional room-code contract.
Rust validator `parse_room_code` | length expected `4` | input `AB` length `2`
expected result `RoomCodeError::InvalidLength { expected: 4, got: 2 }`
other possible error `RoomCodeError::UnsupportedCharacter`What to check
For `AB`, match `RoomCodeError::InvalidLength { expected: 4, got: 2 }`. The test must fail for `RoomCodeError::UnsupportedCharacter`.
Original SKILL.md on GitHub · Updated
Frequently asked question
Does an is_err check verify the length rule?
Assert the variant and relevant fields so another failure mode cannot pass the test.