gots

module
v0.0.0-...-e30cafb Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2014 License: BSD-3-Clause

README

Tideland Go Testing Support

Description

The Tideland Go Testing Support (GOTS) contains the two packages

  • asserts to extend the standard Go testing package and
  • generators for the generating of test data.

Installation

go get github.com/tideland/gots/v3/asserts
go get github.com/tideland/gots/v3/generators

Usage

Asserts

A typical assertion instance for testing is created with

assert := asserts.NewTestingAssertion(t, true)

The true assures that a failing assertion lets also fail the Go test. Now there are several methods like

  • assert.True()
  • assert.Equal()
  • assert.Length()
  • assert.Implementor()
  • assert.Empty()
  • ...

Beside the test they can take an optional last string argument that's been printed in the report if the assert fails.

Generators

The generator helps to generate test data based on a random number generator. This can be ints, words, sentences, paragraphs, male and female names, domains, URLs, e-mail addresses, durations and times. The SimpleRand() returns a Rand based on the current time while FixedRand() returns always the same. Especially the latter helps to produce the same data in different runs:

assert := asserts.NewTestingAssertion(t, false)
genA := generators.New(generators.FixedRand())
genB := generators.New(generators.FixedRand())

urlA := genA.URL()
urlB := genB.URL()
assert.Equal(urlA, urlB)

And now have fun. ;)

Documentation

Authors

License

Tideland Go Testing Support is distributed under the terms of the BSD 3-Clause license.

Directories

Path Synopsis
v3
asserts
The asserts package provides a powerful and convenient set of assertions.
The asserts package provides a powerful and convenient set of assertions.
generators
The generators package contains a generator with a number of functions for the generation of words, sentences, paragraphs, male and female names, domains, URLs and e-mails and more.
The generators package contains a generator with a number of functions for the generation of words, sentences, paragraphs, male and female names, domains, URLs and e-mails and more.

Jump to

Keyboard shortcuts

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