go test个人经验(持续更新)

名称规范

算不上规范。
是我使用 Goland生成 test func的时候的自动命令规则,所以记录一下。

为某个函数编写测试方法:

func Foo() error

func TestFoo(t *testing.T) {
}

为某个struct的方法测试:

type Client struct {}

func (c *Client) Foo() error

func TestClient_Foo(t *testing.T) {
}
posted @ 2023-11-12 17:00  潜行1  阅读(14)  评论(0)    收藏  举报