Documentation ¶
Overview ¶
Package ensure is a balanced testing framework for Go 1.14+. It supports modern Go 1.13+ error comparisons (via errors.Is), and provides easy to read diffs (via deep.Equal).
Most of the implementation is in the ensuring package. ensure.New should be used to create an instance of the ensure framework, which allows shadowing the "ensure" package (like with the t variable in tests). This provides easy test refactoring, while still being able to access the underlying types via the ensuring package.
For example:
func TestBasicExample(t *testing.T) { ensure := ensure.New(t) ... // Methods can be called on ensure, for example, Run: ensure.Run("my subtest", func(ensure ensuring.Ensure) { ... // To ensure a value is correct, use ensure as a function: ensure("abc").Equals("abc") ensure(produceError()).IsError(expectedError) ensure(doNotProduceError()).IsNotError() ensure(true).IsTrue() ensure(false).IsFalse() ensure("").IsEmpty() // Failing a test directly: ensure.Failf("Something went wrong, and we stop the test immediately") }) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
ensure
Module
|
|
Package ensurepkg contains the implementation for the ensure test framework.
|
Package ensurepkg contains the implementation for the ensure test framework. |
Package ensuring contains the implementation for the ensure test framework.
|
Package ensuring contains the implementation for the ensure test framework. |
internal/testhelper
Package testhelper implements helpers for testing ensure.
|
Package testhelper implements helpers for testing ensure. |
exp
|
|
entable
Module
|
|
experiment
|
|
entable
Module
|
|
internal
|
|
mocks/mock_testctx
Package mock_testctx is a generated GoMock package.
|
Package mock_testctx is a generated GoMock package. |
plugins
Package plugins contains interfaces and helpers related to internal plugins for ensure.
|
Package plugins contains interfaces and helpers related to internal plugins for ensure. |
plugins/all
Package all combines all the plugins in the correct order.
|
Package all combines all the plugins in the correct order. |
plugins/internal/id
Package id provides constants used throughout the plugins.
|
Package id provides constants used throughout the plugins. |
plugins/internal/iterate
Package iterate provides helpers for iterating over reflect types and values.
|
Package iterate provides helpers for iterating over reflect types and values. |
plugins/internal/mocks
Package mocks provides an abstracted wrapper around mocks.
|
Package mocks provides an abstracted wrapper around mocks. |
plugins/internal/testhelper
Package testhelper provides helpers for testing the plugins.
|
Package testhelper provides helpers for testing the plugins. |
plugins/mocks
Package mocks provides a plugin that initializes Mocks in the test entry.
|
Package mocks provides a plugin that initializes Mocks in the test entry. |
plugins/setupmocks
Package setupmocks provides a plugin that runs SetupMocks for the provided Mocks.
|
Package setupmocks provides a plugin that runs SetupMocks for the provided Mocks. |
plugins/subject
Package subject provides a plugin that initializes and populates test entry Subject fields using the provided mocks.
|
Package subject provides a plugin that initializes and populates test entry Subject fields using the provided mocks. |
reflectensure
Package reflectensure provides a helper for identifying ensure types via reflection.
|
Package reflectensure provides a helper for identifying ensure types via reflection. |
stringerr
Package stringerr creates errors to be printed by tests.
|
Package stringerr creates errors to be printed by tests. |
tablerunner
Package tablerunner is an internal package that runs table-driven tests.
|
Package tablerunner is an internal package that runs table-driven tests. |
testctx
Package testctx provides a context containing scoped test helpers.
|
Package testctx provides a context containing scoped test helpers. |
Click to show internal directories.
Click to hide internal directories.