NOTE

4.1 unittest

Go unit tests live in files ending in _test.go. These notes use test code to record assertions, execution, and test organization.

GoCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

1. What It Is

Unit testing.

2. Usage

  • Filename: xxx_test.go
  • Import testing
  • The function name must be TestXXX
package array1

import (
	"fmt"
	"reflect"
	"testing"
)

func TestArray1(t *testing.T) {
	slices := []string{"1", "2", "3"}
	fmt.Println(slices)
}
  • Run
    • go test .

3. References

Discussion

Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub