go test 提示 no test files

文章目录

    由于我的 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
    

    关于作者 🌱

    我是来自山东烟台的一名开发者,有感兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊,或者关注我的个人公众号“大象工具”, 查看更多联系方式