Go testing package
Go's standard library package for writing tests, run by the go test command.
In more detail
It has no assertion library; tests compare values themselves and call t.Errorf or t.Fatalf on failure. A test is a function TestXxx(t *testing.T) in a _test.go file.
Examples
func TestDouble(t *testing.T) {}In this course: It has no assertion library; tests compare values themselves and call t.Errorf or t.Fatalf on failure. Table-driven tests play the role of pytest's parametrize.Related terms
- go test — The go subcommand that builds a test binary from the _test.go files in a package, runs every test function and reports what failed.
- test function — A Go function whose name starts with Test and which takes a *testing.T, so go test finds and runs it automatically.
- t.Error and t.Fatal — The *testing.T methods that mark a test as failed: the Error forms continue running the test, the Fatal forms stop it immediately.
- subtest — A named test run inside another test, with its own pass or fail result, often one per case in a table of inputs.
- _test.go file — A Go source file whose name ends in _test.go, which holds tests and is compiled only by go test, never into your binary.
- Go — An open-source programming language from Google, known for simple syntax, fast compilation and built-in concurrency.
- test framework — A library and set of conventions for writing, organising and running automated tests in a language.
- parametrized test — One test function run many times with different data, each run reported as a separate test case.
Taught in
- The Standard testing Package — Concurrent Systems Programming with Go
- Writing Table Driven Tests — Concurrent Systems Programming with Go
- Containerizing and Testing the Final Build — Concurrent Systems Programming with Go
- The Test Pyramid And Where It Is Wrong — Automated Testing, TDD & Quality Engineering
- Introducing pytest — Automated Testing, TDD & Quality Engineering