testivus

package module
v0.0.0-...-681d95e Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2019 License: MIT Imports: 11 Imported by: 0

README

testivus

Documentation

A test helper library for the rest of us. Let your code know how it disappoints you.

Example Usage

package testivus_test

import (
	"testing"

	"github.com/britt/testivus"
)

func TestMain(m *testing.M) {
	exitCode := testivus.Run(m)
	os.Exit(exitCode)
}

func TestTestivus(t *testing.T) {
	if 1 == 2 {
		t.Fail()
	}

	testivus.Grievance(t, "My son tells me your company stinks!")
	testivus.Grievance(t, "You're slow!", "speed").WithError(err)
	testivus.Grievance(t, "You're send too much data!", "speed", "download")
}
Output
> go test -timeout 30s github.com/britt/testivus -v -testivus.outputfile testivus.json

=== RUN   TestTestivus
	DISAPPOINTMENT: My son tells me your company stinks!
	DISAPPOINTMENT: You're slow! (speed)
	DISAPPOINTMENT: You're send too much data! (speed, download)
--- PASS: TestTestivus (0.00s)
PASS

=== The airing of grievances:
I gotta lot of problems with you people! (3 disappointments)

By Tag:
 speed    2 ||
 download 1 |

By Error:
 timeout exceeded 1 |

ok  	github.com/britt/testivus	0.019s

Documentation

Overview

Package testivus adds disappointments to go test. Disappointments are deficiencies that are not quite test failures. Perhaps a function takes too long to run, or touches the file system too many times. Testivus allows to you collect up your grievances and air them at the in the end of your test suite. It builds a report that counts and categorizes your disappointments so that you can better understand compounding failures and spot troublesome pieces of code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(m *testing.M) int

Run can be used in place of TestMain to allow disappointment reporting

Types

type Disappointment

type Disappointment interface {
	String() string
	WithMessage(msg string) Disappointment
	WithError(err error) Disappointment
	WithTags(tags ...string) Disappointment
}

Disappointment is how your code has disappointed you

func Failure

func Failure(t *testing.T, msg string, tags ...string) Disappointment

Failure registers a disappointment and fails the test.

func Grievance

func Grievance(t *testing.T, msg string, tags ...string) Disappointment

Grievance registers a disappointment with your code.

Jump to

Keyboard shortcuts

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