Golang 测试
来源:互联网 发布:宁夏网络教育 编辑:程序博客网 时间:2024/05/22 09:45
go的一些测试的方法,懒得跑结果了, 直接上源代码, 心累!
package main/**go 测试相关的一些测试方法 性能测试 超时测试 基准测试 内容正确性测试 代码覆盖测试**/// 代码覆盖测试// go test -cover -coverprofile=cover.out -covermode=count// go tool -cover -html=cover.out 以html 页面打开结果import ("os""testing""time")func TestA(t *testing.T) {}func TestB(t *testing.T) {}func Benchmark(t *testing.B) {}func sum(n ...int) int {var ret intret = 0for _, i := range n {ret += i}return ret}// go test -v -bench .// go test -v -bench . -benchmem -cpu 1,2,4 -benchtime 30sfunc BenchmakSum(b *testing.B) {for i := 0; i < b.N; i++ {if sum(1, 2, 3) != 6 {b.Fatal("sum fatal error")}}}// benchmark test go test -v -test.bench .func TestMain(m *testing.M) {println("Setup")code := m.Run()println("teardown")os.Exit(code)}// go test -v -run "(?i)sum"func TestSum(t *testing.T) {time.Sleep(time.Second * 2)if sum(1, 2, 3) != 6 {t.Fatal("sum error")}}// timeout test go test -v -timeout 3sfunc TestTimeout(t *testing.T) {time.Sleep(time.Second * 5)}
0 0
- Golang 测试
- golang test测试实例
- golang测试技术
- Golang测试技术
- Golang测试技术
- Golang测试技术
- Golang中的测试
- Golang中的覆盖率测试
- golang:interface{}类型测试
- Golang语言--测试技术
- Golang测试技术
- Golang RPC性能测试
- golang struct继承测试
- 测试golang中的多核多线程
- Golang 单元测试和性能测试
- golang测试hashof 的重复性
- Golang 的二分查找测试
- 测试golang中的多核多线程
- HttpClient 使用get方式发送数据到服务器并下载服务器文件
- com.google.gson.stream.MalformedJsonException的解决办法
- 欢迎使用CSDN-markdown编辑器
- JVM堆内存设置原理
- 基于NX的研发产品设计管理平台实现(一)--概述及目录
- Golang 测试
- 能否实现 Ext.grid.ColumnModel 宽度动态适应
- Javamail体验
- wait和notify实现线程间的通信
- 解决rails5.0 ruby2.3.1下bcryp_ext LoadError: Cannot load such file
- 机器学习基础(林軒田)笔记之七
- Java研发方向如何准备BAT技术面试答案(上)
- 遇见到的一些小细节
- leaflet circle