Pab*_*dez 0 testing conditional-compilation go 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}
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)
}
}
Run Code Online (Sandbox Code Playgroud)
为了避免在每次迭代中运行它,我都设置了// +build slow标志.这应该只在执行时运行,go test -tags slow但不幸的是它每次都在运行(-v标志显示它正在运行).
知道什么是错的吗?
| 归档时间: |
|
| 查看次数: |
61 次 |
| 最近记录: |