go 单元测试使用assert

 

package test

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestSomething(t *testing.T) {
	a := "a"
	b := "b"
    // a是expected
    // b是actual
	assert.Equal(t, a, b, "not equal")
}

文件名以_test结尾。
函数名以Test开头,后续字母开头时首字母大写。

posted on 2025-05-31 20:21  王景迁  阅读(22)  评论(0)    收藏  举报

导航