testza

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: MIT Imports: 14 Imported by: 2

README

testza 🍕

Testza is like pizza for Go - you could life without it, but why should you?

Latest Release Tests Coverage Unit test count Issues


Get The Module | Documentation | Contributing | Code of Conduct


Screenshot of an example test message

Installation

# Execute this command inside your project
go get github.com/MarvinJWendt/testza

Description

Testza is a full-featured testing framework for Go. It integrates with the default test runner, so you can use it with the standard go test tool. Testza contains easy to use methods, like assertions, output capturing, mocking, and much more.

Testza is structured a bit differently than you might be used to in Go, but we think that it makes writing tests as easy and efficient as possible.
After all, writing tests should be very simple and should not require you to study a whole framework.
That's why we made testza to integrate perfectly with your IDE. You don't even have to lookup the documentation, as testza is self-explanatory.

Getting Started

Testza is very IDE friendly and was made to integrate with your IDE to increase your productivity.

   ┌ Testza package
   |    ┌ Container for all testza modules
   |    |     ┌ The module you want to use (Press Ctrl+Space to see a list of all modules)
testza.Use.XXXXXXX


// --- Some Examples ---

// - Some assertions -
testza.Use.Assert.True(t, true) // -> Pass
testza.Use.Assert.NoError(t, err) // -> Pass
testza.Use.Assert.Equal(t, object, object) // -> Pass
// ...

// - Testing console output -
// Test the output of your CLI tool easily!
terminalOutput, _ := testza.Use.Capture.Stdout(func(w io.Writer) error {fmt.Println("Hello"); return nil})
testza.Use.Assert.Equal(t, terminalOutput, "Hello\n") // -> Pass

// - Mocking -
// Testing a function that accepts email addresses as a parameter:

// Testset of many different email addresses
emailAddresses := testza.Use.Mock.Strings.EmailAddresses()

// Run a test for every string in the test set
testza.Use.Mock.Strings.RunTests(t, emailAddresses, func(t *testing.T, index int, str string) {
  user, domain, err := internal.ParseEmailAddress(str) // Use your function
  testza.Use.Assert.NoError(t, err) // Assert that your function does not return an error
  testza.Use.Assert.NotZero(t, user) // Assert that the user is returned
  testza.Use.Assert.NotZero(t, domain) // Assert that the domain is returned
})

// And that's just a few examples of what you can do with Testza!

Documentation

Module Methods
Assert
Click to expand
Capture
Click to expand
Mock.Inputs.Strings
Click to expand
Mock.Inputs.Bools
Click to expand
Mock.Inputs.Floats64
Click to expand
Mock.Inputs.Ints
Click to expand

Assert

testza.Use.Assert.CompletesIn
func CompletesIn(t testRunner, duration time.Duration, f func(), msg ...interface{})

CompletesIn asserts that a function completes in a given time. Use this function to test that functions do not take too long to complete.

NOTE: Every system takes a different amount of time to complete a function. Do not set the duration too low, if you want consistent results.

testza.Use.Assert.Contains
func Contains(t testRunner, object, element interface{}, msg ...interface{})
testza.Use.Assert.Equal
func Equal(t testRunner, expected interface{}, actual interface{}, msg ...interface{})

Equal asserts that two objects are equal.

testza.Use.Assert.EqualValues
func EqualValues(t testRunner, expected interface{}, actual interface{}, msg ...interface{})

EqualValues asserts that two objects have equal values.

testza.Use.Assert.False
func False(t testRunner, value interface{}, msg ...interface{})

False asserts that an expression or object resolves to false.

testza.Use.Assert.Greater
func Greater(t testRunner, object1, object2 interface{}, msg ...interface{})

Greater asserts that the first object is greater than the second.

testza.Use.Assert.Implements
func Implements(t testRunner, interfaceObject, object interface{}, msg ...interface{})

Implements checks if an objects implements an interface.

testza.Use.Assert.Implements(t, (*YourInterface)(nil), new(YourObject))
testza.Use.Assert.Implements(t, (*fmt.Stringer)(nil), new(types.Const)) => pass
testza.Use.Assert.KindOf
func KindOf(t testRunner, expectedKind reflect.Kind, object interface{}, msg ...interface{})

KindOf asserts that the object is a type of kind exptectedKind.

testza.Use.Assert.Less
func Less(t testRunner, object1, object2 interface{}, msg ...interface{})

Less asserts that the first object is less than the second.

testza.Use.Assert.Nil
func Nil(t testRunner, object interface{}, msg ...interface{})

Nil asserts that an object is nil.

testza.Use.Assert.NoError
func NoError(t testRunner, err interface{}, msg ...interface{})

NoError asserts that an error is nil.

testza.Use.Assert.NotCompletesIn
func NotCompletesIn(t testRunner, duration time.Duration, f func(), msg ...interface{})

NotCompletesIn asserts that a function does not complete in a given time. Use this function to test that functions do not complete to quickly. For example if your database connection completes in under a millisecond, there might be something wrong.

NOTE: Every system takes a different amount of time to complete a function. Do not set the duration too high, if you want consistent results.

testza.Use.Assert.NotContains
func NotContains(t testRunner, object, element interface{}, msg ...interface{})
testza.Use.Assert.NotEqual
func NotEqual(t testRunner, expected interface{}, actual interface{}, msg ...interface{})

NotEqual asserts that two objects are not equal.

testza.Use.Assert.NotEqualValues
func NotEqualValues(t testRunner, expected interface{}, actual interface{}, msg ...interface{})

NotEqualValues asserts that two objects do not have equal values.

testza.Use.Assert.NotImplements
func NotImplements(t testRunner, interfaceObject, object interface{}, msg ...interface{})

NotImplements checks if an object does not implement an interface.

testza.Use.Assert.NotImplements(t, (*YourInterface)(nil), new(YourObject))
testza.Use.Assert.NotImplements(t, (*fmt.Stringer)(nil), new(types.Const)) => fail, because types.Const does implement fmt.Stringer.
testza.Use.Assert.NotKindOf
func NotKindOf(t testRunner, kind reflect.Kind, object interface{}, msg ...interface{})

NotKindOf asserts that the object is not a type of kind kind.

testza.Use.Assert.NotNil
func NotNil(t testRunner, object interface{}, msg ...interface{})

NotNil assertsthat an object is not nil.

testza.Use.Assert.NotNumeric
func NotNumeric(t testRunner, object interface{}, msg ...interface{})

Number checks if the object is not a numeric type. Numeric types are: Int, Int8, Int16, Int32, Int64, Float32, Float64, Uint, Uint8, Uint16, Uint32, Uint64, Complex64 and Complex128.

testza.Use.Assert.NotPanic
func NotPanic(t testRunner, f func(), msg ...interface{})

NotPanic asserts that a function does not panic.

testza.Use.Assert.NotZero
func NotZero(t testRunner, value interface{}, msg ...interface{})

NotZero asserts that the value is not the zero value for it's type.

testza.Use.Assert.NotZero(t, 1337)
testza.Use.Assert.NotZero(t, true)
testza.Use.Assert.NotZero(t, "Hello, World")
testza.Use.Assert.Numeric
func Numeric(t testRunner, object interface{}, msg ...interface{})

Numeric asserts that the object is a numeric type. Numeric types are: Int, Int8, Int16, Int32, Int64, Float32, Float64, Uint, Uint8, Uint16, Uint32, Uint64, Complex64 and Complex128.

testza.Use.Assert.Panic
func Panic(t testRunner, f func(), msg ...interface{})

Panic asserts that a function panics.

testza.Use.Assert.True
func True(t testRunner, value interface{}, msg ...interface{})

True asserts that an expression or object resolves to true.

testza.Use.Assert.Zero
func Zero(t testRunner, value interface{}, msg ...interface{})

Zero asserts that the value is the zero value for it's type.

testza.Use.Assert.Zero(t, 0)
testza.Use.Assert.Zero(t, false)
testza.Use.Assert.Zero(t, "")

Capture

testza.Use.Capture.Stderr
func Stderr(capture func(w io.Writer) error) (string, error)

Stderr captures everything written to stderr from a specific function. You can use this method in tests, to validate that your functions writes a string to the terminal.

testza.Use.Capture.Stdout
func Stdout(capture func(w io.Writer) error) (string, error)

Stdout captures everything written to stdout from a specific function. You can use this method in tests, to validate that your functions writes a string to the terminal.

Mock.Inputs.Bools

testza.Use.Mock.Inputs.Bools.Full
func Full() []bool

Full returns true and false in a boolean slice.

testza.Use.Mock.Inputs.Bools.Modify
func Modify(inputSlice []bool, f func(index int, value bool) bool) (floats []bool)

Modify returns a modified version of a test set.

testza.Use.Mock.Inputs.Bools.RunTests
func RunTests(t testRunner, testSet []bool, testFunc func(t *testing.T, index int, f bool))

RunTests runs a test for every value in a testset. You can use the value as input parameter for your functions, to sanity test against many different cases. This ensures that your functions have a correct error handling and enables you to test against hunderts of cases easily.

Mock.Inputs.Floats64

testza.Use.Mock.Inputs.Floats64.Full
func Full() (floats []float64)
testza.Use.Mock.Inputs.Floats64.GenerateRandomNegative
func GenerateRandomNegative(count int, min float64) (floats []float64)

GenerateRandomNegative generates random negative integers with a minimum of min. If the minimum is positive, it will be converted to a negative number. If it is set to 0, there is no limit.

testza.Use.Mock.Inputs.Floats64.GenerateRandomPositive
func GenerateRandomPositive(count int, max float64) (floats []float64)

GenerateRandomPositive generates random positive integers with a maximum of max. If the maximum is 0, or below, the maximum will be set to math.MaxInt64.

testza.Use.Mock.Inputs.Floats64.GenerateRandomRange
func GenerateRandomRange(count int, min, max float64) (floats []float64)

GenerateRandomRange generates random positive integers with a maximum of max. If the maximum is 0, or below, the maximum will be set to math.MaxInt64.

testza.Use.Mock.Inputs.Floats64.Modify
func Modify(inputSlice []float64, f func(index int, value float64) float64) (floats []float64)

Modify returns a modified version of a test set.

testza.Use.Mock.Inputs.Floats64.RunTests
func RunTests(t testRunner, testSet []float64, testFunc func(t *testing.T, index int, f float64))

RunTests runs a test for every value in a testset. You can use the value as input parameter for your functions, to sanity test against many different cases. This ensures that your functions have a correct error handling and enables you to test against hunderts of cases easily.

Mock.Inputs.Ints

testza.Use.Mock.Inputs.Ints.Full
func Full() (ints []int)

Full returns a combination of every integer testset and some random integers (positive and negative).

testza.Use.Mock.Inputs.Ints.GenerateRandomNegative
func GenerateRandomNegative(count, min int) (ints []int)

GenerateRandomNegative generates random negative integers with a minimum of min. If the minimum is 0, or above, the maximum will be set to math.MinInt64.

testza.Use.Mock.Inputs.Ints.GenerateRandomPositive
func GenerateRandomPositive(count, max int) (ints []int)

GenerateRandomPositive generates random positive integers with a maximum of max. If the maximum is 0, or below, the maximum will be set to math.MaxInt64.

testza.Use.Mock.Inputs.Ints.GenerateRandomRange
func GenerateRandomRange(count, min, max int) (ints []int)

GenerateRandomRange generates random integers with a range of min to max.

testza.Use.Mock.Inputs.Ints.Modify
func Modify(inputSlice []int, f func(index int, value int) int) (ints []int)

Modify returns a modified version of a test set.

testza.Use.Mock.Inputs.Ints.RunTests
func RunTests(t testRunner, testSet []int, testFunc func(t *testing.T, index int, i int))

RunTests runs a test for every value in a testset. You can use the value as input parameter for your functions, to sanity test against many different cases. This ensures that your functions have a correct error handling and enables you to test against hunderts of cases easily.

Mock.Inputs.Strings

testza.Use.Mock.Inputs.Inputs.Strings.EmailAddresses
func EmailAddresses() []string

EmailAddresses returns a test set with valid email addresses.

testza.Use.Mock.Inputs.Inputs.Strings.Empty
func Empty() []string

Empty returns a test set with a single empty string.

testza.Use.Mock.Inputs.Inputs.Strings.Full
func Full() (ret []string)

Full contains all string test sets plus ten generated random strings.

testza.Use.Mock.Inputs.Inputs.Strings.GenerateRandom
func GenerateRandom(count, length int) (result []string)

GenerateRandom returns random StringsHelper in a test set.

testza.Use.Mock.Inputs.Inputs.Strings.HtmlTags
func HtmlTags() []string

HtmlTags returns a test set with html tags.

testza.Use.Mock.Inputs.Inputs.Strings.Limit
func Limit(testSet []string, max int) []string

Limit limits a test set in size.

testza.Use.Mock.Inputs.Inputs.Strings.Modify
func Modify(inputSlice []string, f func(index int, value string) string) (ret []string)

Modify returns a modified version of a test set.

testza.Use.Mock.Inputs.Inputs.Strings.Numeric
func Numeric() []string

Numeric returns a test set with strings that are numeric. The highest number in here is "9223372036854775807", which is equal to the maxmim int64.

testza.Use.Mock.Inputs.Inputs.Strings.RunTests
func RunTests(t testRunner, testSet []string, testFunc func(t *testing.T, index int, str string))

RunTests runs a test for every value in a testset. You can use the value as input parameter for your functions, to sanity test against many different cases. This ensures that your functions have a correct error handling and enables you to test against hunderts of cases easily.


Made with ❤️ by @MarvinJWendt and contributors! | MarvinJWendt.com

Documentation

Overview

Package testza is a full-featured testing framework for Go. It integrates with the default test runner, so you can use it with the standard `go test` tool. Testza contains easy to use methods, like assertions, output capturing, mocking, and much more.

Testza is structured a bit differently than you might be used to in Go, but we think that it makes writing tests as easy and efficient as possible. After all, writing tests should be very simple and should not require you to study a whole framework. That's why we made testza to integrate perfectly with your IDE. You don't even have to lookup the documentation, as testza is self-explanatory.

Just type `testza.Use.` and you will get a list of all modules of testza in your IDE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssertHelper

type AssertHelper struct {
}

AssertHelper contains assertion methods for the Go testing system.

func (AssertHelper) CompletesIn

func (a AssertHelper) CompletesIn(t testRunner, duration time.Duration, f func(), msg ...interface{})

CompletesIn asserts that a function completes in a given time. Use this function to test that functions do not take too long to complete.

NOTE: Every system takes a different amount of time to complete a function. Do not set the duration too low, if you want consistent results.

func (AssertHelper) Contains

func (a AssertHelper) Contains(t testRunner, object, element interface{}, msg ...interface{})

func (AssertHelper) Equal

func (a AssertHelper) Equal(t testRunner, expected interface{}, actual interface{}, msg ...interface{})

Equal asserts that two objects are equal.

func (AssertHelper) EqualValues

func (a AssertHelper) EqualValues(t testRunner, expected interface{}, actual interface{}, msg ...interface{})

EqualValues asserts that two objects have equal values.

func (AssertHelper) False

func (a AssertHelper) False(t testRunner, value interface{}, msg ...interface{})

False asserts that an expression or object resolves to false.

func (AssertHelper) Greater

func (a AssertHelper) Greater(t testRunner, object1, object2 interface{}, msg ...interface{})

Greater asserts that the first object is greater than the second.

func (AssertHelper) Implements

func (a AssertHelper) Implements(t testRunner, interfaceObject, object interface{}, msg ...interface{})

Implements checks if an objects implements an interface.

testza.Use.Assert.Implements(t, (*YourInterface)(nil), new(YourObject))
testza.Use.Assert.Implements(t, (*fmt.Stringer)(nil), new(types.Const)) => pass

func (AssertHelper) KindOf

func (a AssertHelper) KindOf(t testRunner, expectedKind reflect.Kind, object interface{}, msg ...interface{})

KindOf asserts that the object is a type of kind exptectedKind.

func (AssertHelper) Less

func (a AssertHelper) Less(t testRunner, object1, object2 interface{}, msg ...interface{})

Less asserts that the first object is less than the second.

func (AssertHelper) Nil

func (a AssertHelper) Nil(t testRunner, object interface{}, msg ...interface{})

Nil asserts that an object is nil.

func (AssertHelper) NoError

func (a AssertHelper) NoError(t testRunner, err interface{}, msg ...interface{})

NoError asserts that an error is nil.

func (AssertHelper) NotCompletesIn

func (a AssertHelper) NotCompletesIn(t testRunner, duration time.Duration, f func(), msg ...interface{})

NotCompletesIn asserts that a function does not complete in a given time. Use this function to test that functions do not complete to quickly. For example if your database connection completes in under a millisecond, there might be something wrong.

NOTE: Every system takes a different amount of time to complete a function. Do not set the duration too high, if you want consistent results.

func (AssertHelper) NotContains

func (a AssertHelper) NotContains(t testRunner, object, element interface{}, msg ...interface{})

func (AssertHelper) NotEqual

func (a AssertHelper) NotEqual(t testRunner, expected interface{}, actual interface{}, msg ...interface{})

NotEqual asserts that two objects are not equal.

func (AssertHelper) NotEqualValues

func (a AssertHelper) NotEqualValues(t testRunner, expected interface{}, actual interface{}, msg ...interface{})

NotEqualValues asserts that two objects do not have equal values.

func (AssertHelper) NotImplements

func (a AssertHelper) NotImplements(t testRunner, interfaceObject, object interface{}, msg ...interface{})

NotImplements checks if an object does not implement an interface.

testza.Use.Assert.NotImplements(t, (*YourInterface)(nil), new(YourObject))
testza.Use.Assert.NotImplements(t, (*fmt.Stringer)(nil), new(types.Const)) => fail, because types.Const does implement fmt.Stringer.

func (AssertHelper) NotKindOf

func (a AssertHelper) NotKindOf(t testRunner, kind reflect.Kind, object interface{}, msg ...interface{})

NotKindOf asserts that the object is not a type of kind `kind`.

func (AssertHelper) NotNil

func (a AssertHelper) NotNil(t testRunner, object interface{}, msg ...interface{})

NotNil assertsthat an object is not nil.

func (AssertHelper) NotNumeric

func (a AssertHelper) NotNumeric(t testRunner, object interface{}, msg ...interface{})

Number checks if the object is not a numeric type. Numeric types are: Int, Int8, Int16, Int32, Int64, Float32, Float64, Uint, Uint8, Uint16, Uint32, Uint64, Complex64 and Complex128.

func (AssertHelper) NotPanic

func (a AssertHelper) NotPanic(t testRunner, f func(), msg ...interface{})

NotPanic asserts that a function does not panic.

func (AssertHelper) NotZero

func (a AssertHelper) NotZero(t testRunner, value interface{}, msg ...interface{})

NotZero asserts that the value is not the zero value for it's type.

testza.Use.Assert.NotZero(t, 1337)
testza.Use.Assert.NotZero(t, true)
testza.Use.Assert.NotZero(t, "Hello, World")

func (AssertHelper) Numeric

func (a AssertHelper) Numeric(t testRunner, object interface{}, msg ...interface{})

Numeric asserts that the object is a numeric type. Numeric types are: Int, Int8, Int16, Int32, Int64, Float32, Float64, Uint, Uint8, Uint16, Uint32, Uint64, Complex64 and Complex128.

func (AssertHelper) Panic

func (a AssertHelper) Panic(t testRunner, f func(), msg ...interface{})

Panic asserts that a function panics.

func (AssertHelper) True

func (a AssertHelper) True(t testRunner, value interface{}, msg ...interface{})

True asserts that an expression or object resolves to true.

func (AssertHelper) Zero

func (a AssertHelper) Zero(t testRunner, value interface{}, msg ...interface{})

Zero asserts that the value is the zero value for it's type.

testza.Use.Assert.Zero(t, 0)
testza.Use.Assert.Zero(t, false)
testza.Use.Assert.Zero(t, "")

type CaptureHelper

type CaptureHelper struct{}

CaptureHelper contains methods to capture terminal output.

func (*CaptureHelper) Stderr

func (h *CaptureHelper) Stderr(capture func(w io.Writer) error) (string, error)

Stderr captures everything written to stderr from a specific function. You can use this method in tests, to validate that your functions writes a string to the terminal.

func (*CaptureHelper) Stdout

func (h *CaptureHelper) Stdout(capture func(w io.Writer) error) (string, error)

Stdout captures everything written to stdout from a specific function. You can use this method in tests, to validate that your functions writes a string to the terminal.

type Helper

type Helper struct {
	Assert  AssertHelper
	Mock    MockHelper
	Capture CaptureHelper
}

Helper contains helper methods for the Go testing system. Methods in here integrate directly with the default Go testing system, and give detailed output. The methods will trigger the test to fail, if your expected behavior didn't occur.

var Use Helper

Use util functions of testza directly in the default testing system of Go. Methods in here integrate directly with the default Go testing system, and give detailed output. The methods will trigger the test to fail, if your expected behavior didn't occur.

type MockHelper

type MockHelper struct {
	Inputs MockInputsHelper
}

MockHelper contains mocking methods for the Go testing system. Do not use this struct directly, use the methods in Use.

type MockInputsBoolsHelper

type MockInputsBoolsHelper struct{}

func (MockInputsBoolsHelper) Full

func (MockInputsBoolsHelper) Full() []bool

Full returns true and false in a boolean slice.

func (MockInputsBoolsHelper) Modify

func (h MockInputsBoolsHelper) Modify(inputSlice []bool, f func(index int, value bool) bool) (floats []bool)

Modify returns a modified version of a test set.

func (MockInputsBoolsHelper) RunTests

func (s MockInputsBoolsHelper) RunTests(t testRunner, testSet []bool, testFunc func(t *testing.T, index int, f bool))

RunTests runs a test for every value in a testset. You can use the value as input parameter for your functions, to sanity test against many different cases. This ensures that your functions have a correct error handling and enables you to test against hunderts of cases easily.

type MockInputsFloats64Helper

type MockInputsFloats64Helper struct{}

MockInputsFloats64Helper contains integer test sets. Use testza.Use.Mock.Inputs.Floats64.

func (MockInputsFloats64Helper) Full

func (h MockInputsFloats64Helper) Full() (floats []float64)

func (MockInputsFloats64Helper) GenerateRandomNegative

func (h MockInputsFloats64Helper) GenerateRandomNegative(count int, min float64) (floats []float64)

GenerateRandomNegative generates random negative integers with a minimum of min. If the minimum is positive, it will be converted to a negative number. If it is set to 0, there is no limit.

func (MockInputsFloats64Helper) GenerateRandomPositive

func (h MockInputsFloats64Helper) GenerateRandomPositive(count int, max float64) (floats []float64)

GenerateRandomPositive generates random positive integers with a maximum of max. If the maximum is 0, or below, the maximum will be set to math.MaxInt64.

func (MockInputsFloats64Helper) GenerateRandomRange

func (h MockInputsFloats64Helper) GenerateRandomRange(count int, min, max float64) (floats []float64)

GenerateRandomRange generates random positive integers with a maximum of max. If the maximum is 0, or below, the maximum will be set to math.MaxInt64.

func (MockInputsFloats64Helper) Modify

func (h MockInputsFloats64Helper) Modify(inputSlice []float64, f func(index int, value float64) float64) (floats []float64)

Modify returns a modified version of a test set.

func (MockInputsFloats64Helper) RunTests

func (s MockInputsFloats64Helper) RunTests(t testRunner, testSet []float64, testFunc func(t *testing.T, index int, f float64))

RunTests runs a test for every value in a testset. You can use the value as input parameter for your functions, to sanity test against many different cases. This ensures that your functions have a correct error handling and enables you to test against hunderts of cases easily.

type MockInputsHelper

type MockInputsHelper struct {
	Strings  MockInputsStringsHelper
	Floats64 MockInputsFloats64Helper
	Ints     MockInputsIntsHelper
	Bools    MockInputsBoolsHelper
}

type MockInputsIntsHelper

type MockInputsIntsHelper struct{}

MockInputsIntsHelper contains integer test sets.

func (MockInputsIntsHelper) Full

func (h MockInputsIntsHelper) Full() (ints []int)

Full returns a combination of every integer testset and some random integers (positive and negative).

func (MockInputsIntsHelper) GenerateRandomNegative

func (h MockInputsIntsHelper) GenerateRandomNegative(count, min int) (ints []int)

GenerateRandomNegative generates random negative integers with a minimum of min. If the minimum is 0, or above, the maximum will be set to math.MinInt64.

func (MockInputsIntsHelper) GenerateRandomPositive

func (h MockInputsIntsHelper) GenerateRandomPositive(count, max int) (ints []int)

GenerateRandomPositive generates random positive integers with a maximum of max. If the maximum is 0, or below, the maximum will be set to math.MaxInt64.

func (MockInputsIntsHelper) GenerateRandomRange

func (h MockInputsIntsHelper) GenerateRandomRange(count, min, max int) (ints []int)

GenerateRandomRange generates random integers with a range of min to max.

func (MockInputsIntsHelper) Modify

func (h MockInputsIntsHelper) Modify(inputSlice []int, f func(index int, value int) int) (ints []int)

Modify returns a modified version of a test set.

func (MockInputsIntsHelper) RunTests

func (s MockInputsIntsHelper) RunTests(t testRunner, testSet []int, testFunc func(t *testing.T, index int, i int))

RunTests runs a test for every value in a testset. You can use the value as input parameter for your functions, to sanity test against many different cases. This ensures that your functions have a correct error handling and enables you to test against hunderts of cases easily.

type MockInputsStringsHelper

type MockInputsStringsHelper struct{}

MockInputsStringsHelper contains strings test sets.

func (MockInputsStringsHelper) EmailAddresses

func (s MockInputsStringsHelper) EmailAddresses() []string

EmailAddresses returns a test set with valid email addresses.

func (MockInputsStringsHelper) Empty

func (s MockInputsStringsHelper) Empty() []string

Empty returns a test set with a single empty string.

func (MockInputsStringsHelper) Full

func (s MockInputsStringsHelper) Full() (ret []string)

Full contains all string test sets plus ten generated random strings.

func (MockInputsStringsHelper) GenerateRandom

func (s MockInputsStringsHelper) GenerateRandom(count, length int) (result []string)

GenerateRandom returns random StringsHelper in a test set.

func (MockInputsStringsHelper) HtmlTags

func (s MockInputsStringsHelper) HtmlTags() []string

HtmlTags returns a test set with html tags.

func (MockInputsStringsHelper) Limit

func (s MockInputsStringsHelper) Limit(testSet []string, max int) []string

Limit limits a test set in size.

func (MockInputsStringsHelper) Modify

func (s MockInputsStringsHelper) Modify(inputSlice []string, f func(index int, value string) string) (ret []string)

Modify returns a modified version of a test set.

func (MockInputsStringsHelper) Numeric

func (s MockInputsStringsHelper) Numeric() []string

Numeric returns a test set with strings that are numeric. The highest number in here is "9223372036854775807", which is equal to the maxmim int64.

func (MockInputsStringsHelper) RunTests

func (s MockInputsStringsHelper) RunTests(t testRunner, testSet []string, testFunc func(t *testing.T, index int, str string))

RunTests runs a test for every value in a testset. You can use the value as input parameter for your functions, to sanity test against many different cases. This ensures that your functions have a correct error handling and enables you to test against hunderts of cases easily.

func (MockInputsStringsHelper) Usernames

func (s MockInputsStringsHelper) Usernames() []string

Usernames returns a test set with usernames.

Directories

Path Synopsis
Custom CI-System for https://github.com/MarvinJWendt/testza.
Custom CI-System for https://github.com/MarvinJWendt/testza.

Jump to

Keyboard shortcuts

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