User Tools

Site Tools


go:tooling:go_test

go test

What is it?

`go test` runs Go unit tests (files ending with `*_test.go`).

What is it used for?

  • Ensure correctness during refactoring.
  • Automated checks in CI pipelines.

Examples

  • Run tests for the current package:
    go test
 
  • Run all tests:
    go test ./...
 
  • Verbose output:
    go test -v ./...
 
  • Coverage:
    go test -cover ./...
 

Hard words (English)

  • unit test /ˈjuːnɪt test/: kiểm thử đơn vị
  • refactor /ˌriːˈfæktər/: tái cấu trúc code
  • coverage /ˈkʌvərɪdʒ/: độ bao phủ test
  • CI (Continuous Integration) /kənˈtɪnjuəs ˌɪntɪˈɡreɪʃən/: tích hợp liên tục
  • pipeline /ˈpaɪplaɪn/: chuỗi quy trình
go/tooling/go_test.txt · Last modified: by phong2018