cairo-testing

star 3

Explain how to write and run Cairo tests, including `#[test]`, assert macros, `#[should_panic]`, `#[ignore]`, and `#[available_gas]`; use when a request involves writing or running unit tests in Cairo.

teddyjfpender By teddyjfpender schedule Updated 1/23/2026

name: cairo-testing description: Explain how to write and run Cairo tests, including #[test], assert macros, #[should_panic], #[ignore], and #[available_gas]; use when a request involves writing or running unit tests in Cairo.

Cairo Testing

Overview

Guide writing test functions, using assertion macros, and running tests with Scarb.

Quick Use

  • Read references/testing.md before answering.
  • Put tests in a #[cfg(test)] module in src files.
  • Use the right assert macro for the expected condition.

Response Checklist

  • Add #[test] above each test function.
  • Use assert!, assert_eq!, assert_ne!, or comparison macros as needed.
  • Assert message arguments must be string literals, not variables (e.g., assert!(x, "msg") not assert!(x, msg)).
  • Use #[should_panic(expected: "...")] for panic-based tests.
  • Use #[ignore] for slow tests and scarb test --include-ignored when needed.
  • Add #[available_gas(n)] for recursion or long loops.

Example Requests

  • "How do I write a basic test in Cairo?"
  • "How do I assert a panic message?"
  • "How do I run a single test?"

Cairo by Example

Install via CLI
npx skills add https://github.com/teddyjfpender/skill-issues --skill cairo-testing
Repository Details
star Stars 3
call_split Forks 0
navigation Branch main
article Path SKILL.md
More from Creator
teddyjfpender
teddyjfpender Explore all skills →