我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

在Go中测试内部构件

The recommended golang test method signature format is:

func TestMxxxx(t *testing.T) {

}

I have noticed if I use 'Testmxxxx', it simply skips the tests. Now, if I have two function in a package, one name myFunc (as private, not exported), and another Myfunc(exported). What will be the approach to write separate test method for each of them?

You can use underscores. E.g.

func Test_mxxxx(t *testing.T) {
    // ...
}

This should run just fine.

近期文章

  • 使用正则表达式的Go-lang错误
  • 通过通道发送数据被卡住
  • Golang中的HTTP服务器与客户端请求
  • Golang mssql驱动程序返回“ mssql:无效的对象名称”
  • 解决反射开销的最佳方法是什么?
  • Gorilla Websocket错误:关闭1007 UTF-8序列非法
  • 最佳实践:含糊不清的接收器的功能与方法?
  • 如何运行没有输出注释的Go示例?
  • 参数在结构上传递方法的语义是否完全由方法而不是调用方确定?
  • template.ParseGlob()可以解析子目录中的模板吗?
  • 使用encoding / xml.Encoder如何将xml标头放在自己的行上?
  • 来自不同渠道的数据进入选择语句是否可以忽略?
  • 等效于Go的Rails控制台
  • 在Go中解压缩tarball
  • 在HTML中取消转义CSS输入
  • Windows符号链接和目录之间的区别
  • 如何在Go中将JSON对象数组转换为具有默认值的结构数组?
  • 指向结构(或缺少结构)的指针
  • Go中解释的字符串文字
  • 反转大猩猩/多路复用器中的子路由器

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华