0

I'm running some tests in golang and I want to avoid running the slow ones, for example this one uses bcrypt so it's slow:

// +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)
    }
}

To avoid running this in every iteration I've set up the // +build slow flag. This should only run when doing go test -tags slow but unfortunately it's running every time (the -v flag shows it's running).

Any idea what's wrong?

4

1 回答 1

5

// +build slow需要后跟一个空行

为了将构建约束与包文档区分开来,一系列构建约束必须后跟一个空行。

访问构建约束

于 2016-03-10T18:56:08.987 回答