【发布时间】:2021-07-16 19:58:54
【问题描述】:
我正在尝试获取项目中所有包的测试覆盖率。
当我执行以下命令时,测试正在成功执行并报告覆盖率。
go test -cover ./...
但是当我使用coverpkg=./... 参数执行go test 时,所有测试都失败了
go test -cover -coverpkg=./... ./...
这是命令的示例输出
srimal@srimal-pc:~/projects/myproject$ go test -v -cover -coverpkg=./... ./...
go build a.abc.com/path/to/module/e2e: no non-test Go files in /home/srimal/projects/driver-selection-handler/e2e
? a.abc.com/path/to/module [no test files]
? a.abc.com/path/to/module/app [no test files]
? a.abc.com/path/to/module/constrain [no test files]
FAIL a.abc.com/path/to/module/directionalhire [build failed]
? a.abc.com/path/to/module/domain [no test files]
FAIL a.abc.com/path/to/module/durationmatrix [build failed]
FAIL a.abc.com/path/to/module/durationmatrix/etaservice [build failed]
FAIL a.abc.com/path/to/module/durationmatrix/roadmatrix [build failed]
2021/04/22 17:23:07 go-util/log: Cannot open config file open config/logger.yaml: no such file or directory
testing: warning: no tests to run
PASS
coverage: 0.0% of statements in ./...
ok a.abc.com/path/to/module/e2e (cached) coverage: 0.0% of statements in ./... [no tests to run]
? a.abc.com/path/to/module/events [no test files]
FAIL a.abc.com/path/to/module/finance [build failed]
? a.abc.com/path/to/module/internal [no test files]
? a.abc.com/path/to/module/internal/config [no test files]
? a.abc.com/path/to/module/internal/logger [no test files]
? a.abc.com/path/to/module/internal/metrics [no test files]
? a.abc.com/path/to/module/internal/profiling [no test files]
? a.abc.com/path/to/module/internal/schema [no test files]
? a.abc.com/path/to/module/internal/stream [no test files]
FAIL a.abc.com/path/to/module/location [build failed]
? a.abc.com/path/to/module/logger [no test files]
? a.abc.com/path/to/module/metrics [no test files]
FAIL a.abc.com/path/to/module/selection [build failed]
FAIL a.abc.com/path/to/module/store [build failed]
FAIL a.abc.com/path/to/module/stream [build failed]
? a.abc.com/path/to/module/stream/reg [no test files]
FAIL a.abc.com/path/to/module/weighted [build failed]
我使用的是 Go 版本 1.15.6
有什么方法可以找到构建失败的原因吗?
【问题讨论】:
-
什么是包,是否只测试以及Go的哪个版本?会不会和这个github问题有关:github.com/golang/go/issues/27333
-
我使用的是 go 版本 1.15.6。上述问题仅针对测试包提出。但在这种情况下,我将测试文件保存在我正在测试的父包下。
-
您正在运行的命令的完整输出是什么?
-
@Christian 将输出添加到问题中
标签: go testing code-coverage go-testing