Create a skill for writing and running tests in the omnirepo.
---
name: testing
description: Write and run tests for Haskell and Python code. Use when adding tests, verifying behavior, or debugging test failures.
---
# Testing
## Running Tests
\`\`\`bash
bild --test Omni/Task.hs # Build and run tests
_/bin/task test # Run tests on existing binary
\`\`\`
## Test Convention
All programs follow the pattern: if first arg is `test`, run tests.
\`\`\`haskell
main :: IO ()
main = do
args <- getArgs
case args of
["test"] -> runTests
_ -> normalMain
\`\`\`
## Writing Tests (Haskell)
Use HUnit or similar:
\`\`\`haskell
runTests :: IO ()
runTests = do
results <- runTestTT $ TestList
[ "parse valid input" ~: parseInput "foo" ~?= Right Foo
, "parse invalid input" ~: parseInput "" ~?= Left "empty"
]
when (failures results > 0) exitFailure
\`\`\`
## Writing Tests (Python)
Use pytest:
\`\`\`python
# : dep pytest
def test_parse_valid():
assert parse_input("foo") == Foo()
def test_parse_invalid():
with pytest.raises(ValueError):
parse_input("")
\`\`\`
## What to Test
- **Happy path** - Does it work with normal input?
- **Edge cases** - Empty, None, max values, boundaries
- **Error cases** - Invalid input, missing data, failures
- **Regressions** - Add test for each bug fix
## Test-Driven Debugging
When something breaks:
1. Write a test that reproduces the bug
2. Verify test fails
3. Fix the code
4. Verify test passes
5. Keep the test
## Test Coverage
Focus on:
- Public API functions
- Complex logic with branches
- Error handling paths
- Integration points
Don't over-test:
- Simple getters/setters
- Obvious wrappers
- Implementation details
Omni/Ide/Test.md