Testing and Debugging
Sui provides built-in tools for testing and debugging Move smart contracts at every stage of development.
What tools can I use to test and debug Move contracts on Sui?
Sui includes a native test framework for Move. You write unit tests directly in your Move source files using the #[test] attribute, which marks a function as a test so that sui move test runs it. For more complex scenarios, the sui::test_scenario module lets you simulate sequences of transactions and inspect object state between steps. Use plain unit tests for logic you can check in a single call, and use test_scenario when a test needs to span multiple transactions or model different user interactions.
To step through execution traces interactively, the Move Trace Debugger integrates with VS Code. When something goes wrong at runtime, the error reference documents common abort codes and their causes.
The main tools available are:
- Unit tests: Write test functions annotated with
#[test]inside your Move modules. Run all tests withsui move test. test_scenario: Simulate multi-transaction flows and model different user interactions in a controlled environment.- Move Trace Debugger: Step through Move execution traces in VS Code to inspect variable state and identify logic errors.
- Error reference: Look up abort codes and error messages to diagnose failures quickly.