如何“测试"项目中的所有测试? [英] How to `go test` all tests in my project?

查看:71
本文介绍了如何“测试"项目中的所有测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

go test命令仅在一个目录中覆盖*_test.go文件.

The go test command covers *_test.go files in only one dir.

我要整个项目go test,这意味着测试应覆盖目录./中的所有*_test.go文件以及目录./下的每个子树目录.

I want to go test the whole project, which means the test should cover all *_test.go files in the dir ./ and every children tree dir under the dir ./.

执行此命令的命令是什么?

What's the command to do this?

推荐答案

这应在当前目录及其所有子目录中运行所有测试:

This should run all tests in current directory and all of its subdirectories:

$ go test ./...

这应该为给定的特定目录运行所有测试:

This should run all tests for given specific directories:

$ go test ./tests/... ./unit-tests/... ./my-packages/...

这应该运行所有以foo/为前缀的导入路径的测试:

This should run all tests with import path prefixed with foo/:

$ go test foo/...

这应该运行所有以foo为前缀的测试导入路径:

This should run all tests import path prefixed with foo:

$ go test foo...

这应该在$ GOPATH中运行所有测试:

This should run all tests in your $GOPATH:

$ go test ...

这篇关于如何“测试"项目中的所有测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆