You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Move语言测试启动失败求助:两种命令均无法正常执行测试

正确的Move语言单元测试启动方式

问题原因解析

  • 使用cargo run --bin move-unit-test报错,是因为该命令仅适用于Move语言核心仓库(Rust项目结构,含Cargo.toml)的开发场景,普通Move项目无需依赖该方式。
  • move sandbox test sources/MyModule.move未执行测试,核心原因是缺少Move项目必备的Move.toml配置文件,导致工具无法正确解析模块依赖与测试注解。

正确操作步骤

1. 搭建标准Move项目结构

确保你的项目目录符合以下结构:

your-project/
├── sources/
│   └── MyModule.move  # 你的模块代码
└── Move.toml          # 项目配置文件(必须创建)

在项目根目录创建Move.toml,示例内容:

[package]
name = "BasicCoinProject"
version = "0.0.1"

[dependencies]
MoveStdlib = { git = "https://github.com/move-language/move.git", rev = "main" }

(注:可根据你使用的Move版本调整rev参数为对应分支或标签)

2. 执行测试命令

在项目根目录(含Move.toml的目录)运行:

move test

该命令会自动扫描sources/目录下带#[test]注解的函数,执行测试并返回结果。

预期测试输出

执行后正常情况会显示:

Running Move unit tests
[ PASS ] 0xCAFE::BasicCoin::test_mint_10
Test result: OK. 1 passed; 0 failed; 0 skipped.

内容的提问来源于stack exchange,提问作者strukovsky

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 12:07:24