Rust testing

From axone-protocol/contracts · View interactive version

Rust testing is an AI agent skill from the GitHub repository axone-protocol/contracts. Patterns for Rust testing in Axone CosmWasm contracts. Use when adding unit tests, integration tests, data-driven cases, or coverage-oriented test scenarios.

How to use this skill

Skill file

Rust Testing

Coverage Targets

| Component | Target |

| -------------------- | ------ |

| Handlers | 100% |

| State operations | 100% |

| Error paths | 90%+ |

| Message parsing | 80%+ |

| Overall | 90%+ |

Minimum Cases to Cover

Running Tests

# Run all unit tests
cargo make test-unit

# Run all tests (includes integration)
cargo make test

# Run tests with coverage
cargo make test-coverage

# Run specific test
cargo test test_name -- --nocapture

Coverage output is written to lcov.info.

Viewing Coverage

# Generate HTML report (requires lcov)
genhtml lcov.info --output-directory coverage/

# Or use cargo-llvm-cov directly
cargo llvm-cov --html --open

Test Design Rules

  1. Isolate tests. Each test should set up its own environment.
  2. Test contract behavior, not framework internals.
  3. Assert exact errors when possible.
  4. Cover edge cases such as zero values, empty strings, and upper bounds.
  5. Prefer descriptive test names without a test_ prefix.
  6. Use tuple-driven cases for simple matrices and structs only when the case shape needs named fields.

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.