在复杂的文件夹结构中进行测试 [英] go test in complex folder structure

查看:50
本文介绍了在复杂的文件夹结构中进行测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用golang建立设计模式库.要运行所有测试,我使用此bash脚本.可以.

I am building a repository of design patterns in golang. To run all tests, I use this bash script. It works.

#!/bin/bash
go test creational/abstract_factory/*.go
go test creational/builder/*.go
go test creational/factory/*.go
go test creational/pool/*.go
go test creational/prototype/*.go
go test creational/singleton/*.go

工作正常:

prompt> ./runtests.sh
ok      command-line-arguments  0.006s
ok      command-line-arguments  0.006s
ok      command-line-arguments  0.006s
ok      command-line-arguments  0.006s
ok      command-line-arguments  0.005s
ok      command-line-arguments  0.006s

但是,...如果我尝试将更多目录发送到 go test ,则会收到此消息:命名文件必须全部在一个目录中;具有creational/pool/和creational/factory/".这就是我创建该bash脚本的原因.

But, ... If I try to send more directory to go test I receive this message "named files must all be in one directory; have creational/pool/ and creational/factory/". This is the reason I've created that bash script.

是否可以在一个命令中测试所有文件夹?

Is there the possibility to test all folder in one single command?

推荐答案

使用 ... 有什么问题?将目录更改为 creative ,然后

What's wrong with using the ...? Change directory to creational, then

go test ./...

这将递归到所有子文件夹并对找到的所有软件包执行测试.有关详细信息,请参见调用go时的输出差异使用包进行测试;和如何当测试文件在模块中时,您会运行去测试"吗?

This will recurse to all subfolders and execute tests of all packages found. For details, see Difference in output when calling go test with package; and How do you run `go test` when test files are within a module?

注意:从1.9开始,如果使用./... ,则 vendor 子文件夹中的软件包不匹配.来源:转到1.9版本说明-供应商与./... 匹配.在Go 1.9之前, go test ./...也进入了 vendor 子文件夹并运行了供应商软件包的测试.

Note: starting with 1.9, packages in vendor subfolders are not matched if ./... is used. Source: Go 1.9 Release Notes - Vendor matching with ./.... Prior to Go 1.9, go test ./... also went into the vendor subfolder and ran tests of vendored packages.

这篇关于在复杂的文件夹结构中进行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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