Skip to content

golovers/gotest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Testing in Go

Structure:

xxx.go
xxx_test.go
    TestXXX(t *testing.T)
    BenchmarkXXX(t *testing.B)
xxx_integration_test.go
    TestXXX(t *testing.T)
testdata/
    xxx.txt
    xxy.csv

Basic commands:

go test
go test -v
go test ./...
go test -run=TestRotate

Benchmark

go test -benchmem -bench=.

Coverage

go test -cover
go test ./... -coverprofile=coverage.out
go tool cover -func=coverage.out
go tool cover -html=coverage.out

Test suite

xxx_integration_test.go
    // +build integration
go test -tags=integration

HTTP:

httptest.ResponseRecorder
httptest.Server

Mocks:

https://github.com/golang/mock

Blogs:

https://blog.golang.org/cover

About

Examples of testing in Go: basic, HTTP, Mock

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages