go test 提示 no test files

发布时间: 2020-04-01 10:41:01 作者: 大象笔记

由于我的 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
我是一名山东烟台的开发者,联系作者