go test 可以执行单元测试 , 一般把所有go文件测试单元都执行一遍
现在如果想要执行某一个指定的测试函数 , 可以像这样
go test -v -run 测试函数名字
例如:
rpc_test.go
package tools
import (
"go-fly-muti/frpc"
"testing"
)
func TestClientRpc(t *testing.T) {
frpc.ClientRpc()
}
func TestServerRpc(t *testing.T) {
frpc.NewRpcServer("127.0.0.1:8082")
}
执行 TestClientRpc函数
go test -v -run TestClientRpc
本文介绍了如何使用`go test`命令来执行Go语言中的特定单元测试函数。通过`go test -v -run=测试函数名字`,可以针对性地运行如`TestClientRpc`这样的测试用例,这在调试和测试特定功能时非常有用。

被折叠的 条评论
为什么被折叠?



