cogol

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

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

Go to latest
Published: Oct 8, 2021 License: MIT Imports: 6 Imported by: 0

README

Cogol

Go Reportcard Release Build

Cogol

Why Cogol?

Cogol is a beautiful, easy-configurable tool for writing unit-tests in Go programming language.

Getting started

Install Cogol by running

$ go get github.com/kyeeego/cogol

Next, create typical *_test.go file and copy and paste the following code inside it.

package test

import (
	"github.com/kyeeego/cogol"
	"testing"
)

func TestSomething(t *testing.T) {
	cgl := cogol.Init(t)

	g := cgl.Group("test")
	{
		g.T("Adds two numbers", func(c *cogol.Context) {
			c.Expect(2 + 2).ToBe(4)
		})
	}

	cgl.Process()
}

Run it with

$ go test

and get the following output

Cogol test results

You successfully wrote your first test with Cogol!

Documentation

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cogol

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

func Init

func Init(t *testing.T) *Cogol

Init creates a new Cogol instance from *testing.T taken from Go's typical test function

func (*Cogol) Group

func (cgl *Cogol) Group(name string) *group

Group is a function that creates a new group (G instance)

func (*Cogol) Process

func (cgl *Cogol) Process()

Process runs all the groups of a Cogol instance, calculating it's success and then reporting

type Context

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

func (*Context) Expect

func (ctx *Context) Expect(actual interface{}) *assertion

Expect creates a new assertion with actual value and nil as an expected one

func (*Context) Kill

func (ctx *Context) Kill(message string)

Kill marks test as failed and stops it's processing

func (*Context) Log

func (ctx *Context) Log() Logger

func (*Context) Storage

func (ctx *Context) Storage() Storage

func (*Context) UseKiller

func (ctx *Context) UseKiller(killer func(f *failure))

UseKiller allows users to use custom assertion killers

type Logger

type Logger interface {
	Info(text string)
	Infof(format string, args ...interface{})
	Error(text string)
	Errorf(format string, args ...interface{})
}

type Reporter

type Reporter interface {
	Group(g *group)
	Test(test *test)
	Todo(todo string)
	Error(f *failure)
	Print(format string, values ...interface{})
}

type Storage

type Storage interface {
	Get(key string) interface{}
	Set(key string, value interface{})
}

Jump to

Keyboard shortcuts

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