go test报错 wrong signature for TestAdd, must be: func TestAdd(t *testing.T)
参考: https://www.cnblogs.com/mingbai/p/gotesterr.html
背景
学习 Go 过程中,在终端输入 go test 显示报错:
1 | wrong signature for TestAdd, must be: func TestAdd(t *testing.T) |
后经搜索该报错查明示由于 func TestAdd(t testing.T) 参数未带 *,需要改为 func TestAdd(t *testing.T)
问题复现
报错代码如下:
1 | // calculation_util_test.go |
如何解决
修改后的代码:
1 | // calculation_util_test.go |
测试通过!
go test报错 wrong signature for TestAdd, must be: func TestAdd(t *testing.T)
