Test structure
Move tests are written in the same file as your module or in separate test modules:Using test scenario
Thetest_scenario module simulates multi-transaction scenarios:
Test scenario API
Transaction management
Object operations
Testing patterns
Test owned objects
Test shared objects
Test immutable objects
Test utilities
Thetest_utils module provides helpful testing functions:
Running tests
Expected failures
Test functions that should abort:Debugging techniques
Use debug print (test-only)
Add descriptive assertions
Test incrementally
Break complex tests into smaller pieces:Common test patterns
Test module initialization
Test object transfers
Best practices
- Test all code paths: Cover success and failure cases
- Use meaningful test names: Describe what is being tested
- Keep tests focused: One concept per test
- Use constants for addresses: Makes tests more readable
- Clean up resources: Always call
ts.end() - Test edge cases: Zero values, maximum values, empty vectors
- Test permissions: Verify authorization checks work
Next steps
IOTA Move framework
Learn about built-in IOTA framework modules
Best practices
Follow Move development best practices