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
标签:re,testing,test,add,测试用例,func,go
From: https://www.cnblogs.com/postkarte/p/17788341.html