How do I use a dependency just for tests?

46 views Asked by At

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?

1

There are 1 answers

0
Daniel Porteous On BEST ANSWER

Close! You can do it like this:

#[test_only]
use aptos_framework::aptos_account;