Testing 有条件地运行生成标志不起作用的测试
我正在golang中运行一些测试,我希望避免运行速度较慢的测试,例如,此测试使用bcrypt,因此速度较慢:Testing 有条件地运行生成标志不起作用的测试,testing,go,conditional-compilation,property-based-testing,Testing,Go,Conditional Compilation,Property Based Testing,我正在golang中运行一些测试,我希望避免运行速度较慢的测试,例如,此测试使用bcrypt,因此速度较慢: // +build slow package services import ( "testing" "testing/quick" ) // using bcrypt takes too much time, reduce the number of iterations. var config = &quick.Config{MaxCount: 20}
// +build slow
package services
import (
"testing"
"testing/quick"
)
// using bcrypt takes too much time, reduce the number of iterations.
var config = &quick.Config{MaxCount: 20}
func TestSignaturesAreSame(t *testing.T) {
same := func(simple string) bool {
result, err := Encrypt(simple)
success := err == nil && ComparePassWithHash(simple, result)
return success
}
if err := quick.Check(same, config); err != nil {
t.Error(err)
}
}
为了避免在每次迭代中都运行它,我设置了/+buildslow
标志。这应该只在执行go test-tags slow
时运行,但不幸的是它每次都在运行(v标志显示它正在运行)
你知道怎么回事吗?你的
//+buildslow
后面需要一个空行
为了区分构建约束和包文档,一系列构建约束后面必须有一个空行
访问您的
//+build slow
后面需要一个空行
为了区分构建约束和包文档,一系列构建约束后面必须有一个空行
访问“要区分生成约束和包文档,一系列生成约束后面必须有一个空行。”我认为包测试已经有了一个用-short触发的“short”模式。“要区分生成约束和包文档,一系列生成约束后面必须有一个空行。”我认为包测试已经有了一个用-short触发的“short”模式。