Move script unit test #144
-
Is there any way to write unit tests for move scripts? |
Beta Was this translation helpful? Give feedback.
Answered by
kshitijc1506
Apr 16, 2024
Replies: 1 comment 3 replies
-
You can use the
You can run your tests using the CLI: Here are the docs on unit tests. In theory, you could perform unit tests "off-chain" by invoking transactions via scripts. Scripts can call |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You cannot use
aptos move test
for yourdeposit_and_withdraw
script function. Unlike modules, scripts cannot declare structs, friends, or have persistent storage, and they cannot be directly unit tested using theaptos move test
command.You should write your unit tests using the
#[test]
attribute in your modules. You can then call invoke those test functions by using scripts (or just the CLI command). If you need to test the script's logic itself, you would typically do this using a testing framework in your backend (typescript/rust/python), or by observing behavior after deployment to testnet/devnet (this is more integration testing).