mojo-test-runner
Run Mojo tests using mojo test command. Use when executing tests or verifying test coverage.
When & Why to Use This Skill
The Mojo Test Runner skill automates the execution and management of test suites for the Mojo programming language. It streamlines the software development lifecycle by providing efficient tools for running tests, verifying implementation correctness, and monitoring test coverage, ensuring high-quality code delivery and robust error handling.
Use Cases
- Automated Regression Testing: Execute comprehensive test suites using the `mojo test` command to ensure that new updates or refactors do not introduce regressions.
- Test-Driven Development (TDD): Support the red-green-refactor cycle by running specific test files or pattern-matched tests for rapid feedback during the coding process.
- Continuous Integration & Pre-merge Validation: Verify code correctness and test coverage metrics before merging pull requests to maintain a stable and reliable codebase.
- Debugging and Error Isolation: Utilize verbose output and targeted execution to diagnose specific failures such as syntax errors, memory ownership issues, or logic bugs in Mojo applications.
| name | mojo-test-runner |
|---|---|
| description | "Run Mojo tests using mojo test command. Use when executing tests or verifying test coverage." |
| mcp_fallback | none |
| category | mojo |
| agent | test-engineer |
| user-invocable | false |
Mojo Test Runner Skill
Execute Mojo tests with filtering and reporting.
When to Use
- Running Mojo test suites
- Verifying implementation correctness
- TDD red-green-refactor cycle
- Checking test coverage before PR
Quick Reference
# Run all tests
mojo test tests/
# Run specific file
mojo test tests/test_tensor.mojo
# Run with verbose output
mojo test -v tests/
# Run tests matching pattern
./scripts/run_tests.sh tensor
Workflow
- Run tests - Execute
mojo testor script - Review output - Check pass/fail summary
- Fix failures - Address failing tests
- Re-run tests - Verify all pass
Mojo-Specific Notes
- Test functions must start with
test_ - Test files must match
test_*.mojoor*_test.mojo - Tests run independently - no shared state between tests
- Use
raiseskeyword for exception testing
Error Handling
| Error | Cause | Solution |
|---|---|---|
Import error |
Module not found | Verify -I include paths |
Syntax error |
Invalid test code | Fix syntax before testing |
Timeout |
Test too slow | Optimize or increase timeout |
Memory error |
Ownership issue | Check ownership and borrowing |
References
.claude/shared/mojo-anti-patterns.md- Common test mistakes/notes/review/- Testing strategy documentation