Standard library / testing

testing.T.Skip()

Log a reason and terminate the calling test goroutine as skipped. Cleanup still runs. Expected stdout: 'cleanup\nPASS\n'. Run as a _test.go file using the Go test harness.

Formal Syntax & Structure

go syntaxgo
func (c *T) Skip(args ...any)

Parameters & Attributes

NameTypeDescription
args...anyArguments supplied to logging, skipping or corpus entry as applicable.

Working Example

Example Snippetgo
package main
import (  "fmt"  "testing")
func TestReference(t *testing.T) {  t.Cleanup(func() { fmt.Println("cleanup") })  t.Skip("optional fixture unavailable")}
Go Reference