go test跳过某个测试用例

package ch11

func add(a, b int) int {
	return a + b
}

package ch11

import (
	"fmt"
	"testing"
)

func TestAdd(t *testing.T) {
	re := add(1, 4)

	if re != 5 {
		t.Errorf("expect %d, actual %d", 3, re)
	}
}

func TestAdd2(t *testing.T) {
	if testing.Short() {
		t.Skip("short 模式下跳过")
	}
	fmt.Println("6666666")
	re := add(1, 5)
	if re != 6 {
		t.Errorf("expect %d actual %d", 6, re)
	}
}

运行如下命令测试时候可以跳过

go test -short
posted @ 2023-10-25 22:53  Postkarte  阅读(173)  评论(0)    收藏  举报