movemove-langaptos

How do I use a dependency just for tests?


Move is generally pretty Rust-like, the syntax for using dependencies looks very similar:

use aptos_framework::aptos_account;

As such, I'd expect that if I want to use something only in tests, I'd do this:

#[cfg(test)]
use aptos_framework::aptos_account;

However this doesn't work in Move, I suppose because there is no notion of cfg (indeed, a search through all the Move code in aptos-core finds no use of cfg). In that case, how do I use a dependency only for tests?


Solution

  • Close! You can do it like this:

    #[test_only]
    use aptos_framework::aptos_account;