go test 提示 no test files

更新日期: 2020-04-01 阅读次数: 14064 字数: 120 分类: golang

由于我的 golang 测试代码写在子目录下,而项目根目录下没有任何测试代码文件。所以在执行测试时,提示 no test files。

go test -v
?       sunzhongwei.com/go_tool [no test files]

解决方法一

> go test -v ./...
?       sunzhongwei.com/go_tool [no test files]
?       sunzhongwei.com/go_tool/controllers     [no test files]
?       sunzhongwei.com/go_tool/models  [no test files]
=== RUN   TestIsMobile
--- PASS: TestIsMobile (0.00s)
PASS
ok      sunzhongwei.com/go_tool/utils   0.029s

解决方法二

进入子目录执行:

> cd utils/
> go test -v

tags: golang 自动化测试

关于作者 🌱

我是来自山东烟台的一名开发者,有敢兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊, 查看更多联系方式