补充单元测试
This commit is contained in:
parent
1c7fd10b53
commit
bb8d788610
@ -77,3 +77,18 @@ type Stringer interface {
|
||||
|
||||
## debug 测试
|
||||
|
||||
才是一个程序员入门的标准,
|
||||
|
||||
Debug是一个什么事儿: 让你的代码 一行一行的运行,你人肉观察 程序的每一步 是否符合你的预期(这里的变量是不是对的)
|
||||
|
||||
|
||||
1. 添加程序断点: 程序停止那里,等待运行
|
||||
|
||||

|
||||
|
||||
+ Continue: 继续到下一个端点
|
||||
+ Step Over: 下一步
|
||||
+ Step In: 单步调试
|
||||
+ Step Out: 跳出当前调试步骤
|
||||
|
||||
学了Debug 遇到了问题,写个单元测试,看程序每一步的运行状态是否是正确的。
|
BIN
book/config/image-2.png
Normal file
BIN
book/config/image-2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
@ -7,6 +7,7 @@ import (
|
||||
)
|
||||
|
||||
// LoadConfigFromYaml
|
||||
// go test 它自动帮你写来一个main函数,然后把测试逻辑装进去, 然后编译允许
|
||||
func TestLoadConfigFromYaml(t *testing.T) {
|
||||
if err := config.LoadConfigFromYaml("application.yaml"); err != nil {
|
||||
// 报错测试失败,并且结束
|
||||
|
Loading…
x
Reference in New Issue
Block a user