blog icon indicating copy to clipboard operation
blog copied to clipboard

Go Test 单元测试简明教程 | 快速入门 | 极客兔兔

Open geektutu opened this issue 5 years ago • 6 comments

https://geektutu.com/post/quick-go-test.html

本文介绍了Go语言(golang) 如何写单元测试(unit tests),详细介绍了标准库 testing 的使用。包括子测试(subtests),帮助函数(helpers),setup 和 teardown 机制,网络测试(Network, http) 和基准测试(benchmark)

geektutu avatar Feb 10 '20 15:02 geektutu

您的爱,太阳一般温暖,春风一般和煦,清泉一般甘甜。您的爱,比父爱更严峻,比母爱更细腻,比友爱更纯洁。您的爱,天下最伟大,最高洁。

wilgx0 avatar Sep 01 '20 03:09 wilgx0

写得太好啦!学习了。谢谢博主

ethanschen avatar Mar 15 '21 03:03 ethanschen

文中的例子有一处错误:当t.Helper()下一行接t.Run(c.Name, func(t *testing.T) {...的时候,当test case出错时,控制台输出并不会定位到出错的test case那一行代码

dgqypl avatar Sep 08 '21 08:09 dgqypl

网站挂了,求修复

cyniczhi avatar Nov 04 '21 10:11 cyniczhi

@dgqypl 文中的例子有一处错误:当t.Helper()下一行接t.Run(c.Name, func(t *testing.T) {...的时候,当test case出错时,控制台输出并不会定位到出错的test case那一行代码

我也遇到了这个问题

FoBoHuang avatar Jan 10 '22 16:01 FoBoHuang

@dgqypl 文中的例子有一处错误:当t.Helper()下一行接t.Run(c.Name, func(t *testing.T) {...的时候,当test case出错时,控制台输出并不会定位到出错的test case那一行代码

在"func(t *testing.T) {"后第一行,加t.Helper()即可。

wesley2005 avatar May 31 '22 03:05 wesley2005