1

I'm learning Move language and I'd like to run tests to make sure my module is valid. Here is example taken from docs (file sources/MyModule.move):


module 0xCAFE::BasicCoin {
    #[test_only]
    use std::signer;

    struct Coin has key {
        value: u64,
    }

    public fun mint(account: signer, value: u64) {
        move_to(&account, Coin { value })
    }


    #[test(account = @0xC0FFEE)]
    fun test_mint_10(account: signer) acquires Coin {
        let addr = signer::address_of(&account);
        mint(account, 10);
        assert(borrow_global<Coin>(addr).value == 10, 0);
    }
}

Documentation says I need to start tests using

cargo run --bin move-unit-test MyModule.move
But I cannot since I get

error: could not find `Cargo.toml` in `.../move-playground` or any parent directory

If I launch tests using move sandbox test sources/MyModule.move then I will get no tests executed:

0 / 0 test(s) passed.

How shall one start tests?

Progman
  • 16,827
  • 6
  • 33
  • 48
strukovsky
  • 11
  • 1
  • I'm not sure what environment you're developing in but if you're building Move for Aptos, you can use the Aptos CLI for this (which contains the Move compiler). You could run a command like this from inside your Move module directory: `aptos move test`. Learn more here: https://aptos.dev/move/move-on-aptos/cli. – Daniel Porteous Jun 18 '23 at 10:54

0 Answers0