goassert

package module
v0.0.0-...-bb8cd32 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2018 License: MIT Imports: 4 Imported by: 0

README

Package goassert provides an assertion framework making your testing easier and happier.

Build Status Report Status

Copyright 2017- Tatsuhiro Aoshima (hiro4bbh@gmail.com).

Abstract

Package goassert provides an assertion framework making your testing easier and happier. See documents on GoDoc for details.

Documentation

Overview

Package goassert provides an assertion framework making your testing easier and happier

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assert

type Assert struct {
	// contains filtered or unexported fields
}

Assert is an assertion wrapper.

func New

func New(tb TestingTB, expected ...interface{}) *Assert

New returns a new Assert with the testing context and the expected values.

func (*Assert) Equal

func (assert *Assert) Equal(actual ...interface{})

Equal checks that the given actual values equals the expected values.

func (*Assert) EqualWithoutError

func (assert *Assert) EqualWithoutError(actualErr ...interface{})

EqualWithoutError checks that the given actual values equals the expected values without any error.

func (*Assert) ExpectError

func (assert *Assert) ExpectError(_err ...interface{})

ExpectError checks that the error is returned expectedly. The expected values must be none or one error pattern string.

func (*Assert) ExpectPanic

func (assert *Assert) ExpectPanic(callback func())

ExpectPanic checks that panic is called at least once. The expected values must be one expected object passed to panic.

func (*Assert) SucceedNew

func (assert *Assert) SucceedNew(o interface{}, err error) interface{}

SucceedNew checks that New-style function succeeds without any error.

func (*Assert) SucceedWithoutError

func (assert *Assert) SucceedWithoutError(err error)

SucceedWithoutError check that the function succeeds without any error.

type HookedTestingTB

type HookedTestingTB struct {
	// Messages is the slice of the logged messages.
	Messages []string
	// Helpers is the slice of the registered helper functions.
	// Helper functions are identified by string "file:line".
	Helpers []string
	// contains filtered or unexported fields
}

HookedTestingTB implements TestingTB. This is designed to be used in testing test frameworks.

func NewHookedTestingTB

func NewHookedTestingTB(name string) *HookedTestingTB

NewHookedTestingTB returns a new HookedTestingTB.

func (*HookedTestingTB) Error

func (tb *HookedTestingTB) Error(args ...interface{})

Error is for interface TestingTB.

func (*HookedTestingTB) Errorf

func (tb *HookedTestingTB) Errorf(format string, args ...interface{})

Errorf is for interface TestingTB.

func (*HookedTestingTB) Fail

func (tb *HookedTestingTB) Fail()

Fail is for interface TestingTB.

func (*HookedTestingTB) FailNow

func (tb *HookedTestingTB) FailNow()

FailNow is for interface TestingTB.

func (*HookedTestingTB) Failed

func (tb *HookedTestingTB) Failed() bool

Failed is for interface TestingTB.

func (*HookedTestingTB) Fatal

func (tb *HookedTestingTB) Fatal(args ...interface{})

Fatal is for interface TestingTB.

func (*HookedTestingTB) Fatalf

func (tb *HookedTestingTB) Fatalf(format string, args ...interface{})

Fatalf is for interface TestingTB.

func (*HookedTestingTB) Helper

func (tb *HookedTestingTB) Helper()

Helper is for interface TestingTB.

func (*HookedTestingTB) Log

func (tb *HookedTestingTB) Log(args ...interface{})

Log is for interface TestingTB.

func (*HookedTestingTB) Logf

func (tb *HookedTestingTB) Logf(format string, args ...interface{})

Logf is for interface TestingTB.

func (*HookedTestingTB) Name

func (tb *HookedTestingTB) Name() string

Name is for interface TestingTB.

type TestingTB

type TestingTB interface {
	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Fail()
	FailNow()
	Failed() bool
	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})
	Log(args ...interface{})
	Logf(format string, args ...interface{})
	Name() string
	Helper()
}

TestingTB is an interface mimicking testing.TB (except for Skip*) interface which prevents users to implement itself. See testing.TB for details.

Jump to

Keyboard shortcuts

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