Move Unit Testing
Running Tests
Execute Move unit tests:Basic Testing
Test Options
Parallel Execution
Gas Limits
List Tests
Coverage
Test Patterns
Basic Test
Expected Failure
Test-Only Functions
Test Scenarios
Transaction Testing
Dry Run
Simulate transaction execution without committing:Example
Dev Inspect
Inspect transaction execution with detailed debugging:Example
- Return values
- Events emitted
- Gas usage
- Object changes
- Error details (if any)
Transaction Digest
Compute transaction digest without executing:Serialized Transactions
Serialize transaction for later execution:Local Network Testing
Quick Test Cycle
Persistent Testing
Test with state preservation:Integration Testing
Multi-Package Testing
Test interactions between multiple packages:Multi-Signature Testing
Test MultiSig transactions:Replay Testing
Replay Transactions
Replay past transactions for debugging:Replay Batches
Replay multiple transactions:Replay Checkpoints
Replay transactions from checkpoint range:Coverage Analysis
Collect Coverage
Gas Profiling
Profile Transaction
Analyze Profile
View in speedscope
Open https://www.speedscope.app/ and load
gas_profile.json.Bytecode Verification
Verify Meter
Check bytecode complexity limits:Options
--package <PATH>- Package to verify--protocol-version <VERSION>- Protocol version--module <PATH>...- Specific modules to verify
Examples
Verify Source
Verify on-chain bytecode matches local source:Options
--verify-deps- Also verify dependencies--skip-source- Only verify dependencies--address-override <ADDRESS>- Override package address
Example
Testing Best Practices
Unit Test Guidelines
-
Test all public functions:
-
Test error conditions:
-
Use test-only helpers:
-
Test scenarios:
Integration Test Workflow
-
Start clean network:
-
Deploy all packages:
-
Run integration tests:
-
Verify state:
Testnet Testing
-
Deploy to testnet:
-
Automated testing:
-
Monitor results:
Continuous Integration
Integrate testing into CI/CD:.github/workflows/test.yml
Troubleshooting
Test Failures
Error:Test exceeded gas limit
Solution:
Test timed out
Check for infinite loops or expensive operations.
Dry Run Issues
Error:Insufficient gas
Solution:
Object not found
Verify object exists and is owned by sender:
Network Issues
Error:Connection refused
Ensure network is running:
Next Steps
Move Commands
Build and publish packages
Transaction Builder
Create complex transactions
Local Network
Set up testing environment
Client Commands
Interact with the network