tap

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2026 License: BSD-2-Clause Imports: 2 Imported by: 0

README

tap

A tiny TAP (Test Anything Protocol) implementation for Go

https://testanything.org/

Example

package main

import (
	"machine"
	"time"

	"tinygo.org/x/tap"
)

func main() {
	waitForStart()

	t := tap.New()
	t.Header(4)

	if digitalReadVoltageGPIO() {
		t.Pass("digitalReadVoltage (GPIO)")
	} else {
		t.Fail("digitalReadVoltage (GPIO)")
	}

	if digitalWriteGPIO() {
		t.Pass("digitalWrite (GPIO)")
	} else {
		t.Fail("digitalWrite (GPIO)")
	}

	if i2cConnection() {
		t.Pass("i2cConnection (MPU6050)")
	} else {
		t.Fail("i2cConnection (MPU6050)")
	}

	if spiTxRx() {
		t.Pass("spiTxRx")
	} else {
		t.Fail("spiTxRx")
	}

	endTests()
}

Documentation

Overview

package tap provides a simple TAP (Test Anything Protocol) implementation for Go. It is designed to be used in test code, and provides methods to generate TAP output indicating test results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tester

type Tester struct {

	// TODO toggles the TODO directive for Ok, Fail, Pass, and similar.
	TODO bool
	// contains filtered or unexported fields
}

Tester is a type to encapsulate test state. Methods on this type generate TAP output.

func New

func New() *Tester

func (*Tester) Diagnostic

func (t *Tester) Diagnostic(message string)

Diagnostic generates a diagnostic from the message, which may span multiple lines.

func (*Tester) Fail

func (t *Tester) Fail(description string)

Fail indicates that a test has failed. This is typically only used when the logic is too complex to fit naturally into an Ok() call.

func (*Tester) Header

func (t *Tester) Header(testCount int)

Header displays a TAP header including version number and expected number of tests to run.

func (*Tester) Ok

func (t *Tester) Ok(test bool, description string)

Ok generates TAP output indicating whether a test passed or failed.

func (*Tester) Pass

func (t *Tester) Pass(description string)

Pass indicates that a test has passed. This is typically only used when the logic is too complex to fit naturally into an Ok() call.

func (*Tester) Skip

func (t *Tester) Skip(count int, description string)

Skip indicates that a test has been skipped.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL