Documentation
¶
Overview ¶
Package allure provides Allure provider as a plugin for testo.
Index ¶
- func Setup[T testo.CommonT](t T, name string, f func(t T), options ...plugin.Option)
- func Step[T testo.CommonT](t T, name string, f func(t T), options ...plugin.Option)
- func TearDown[T testo.CommonT](t T, name string, f func(t T), options ...plugin.Option)
- func WithCategories(categories ...Category) plugin.Option
- func WithDefaultTitle(f TitleFunc) plugin.Option
- func WithGroupParametrized() plugin.Option
- func WithLinkTransformer(f LinkTransformerFunc) plugin.Option
- func WithOutputDir(dir string) plugin.Option
- type Allure
- func (a *Allure) Attach(name string, attachment Attachment)
- func (a *Allure) Description(desc string)
- func (a *Allure) Descriptionf(format string, args ...any)
- func (a *Allure) Epic(epic string)
- func (a *Allure) Feature(feature string)
- func (a *Allure) Flaky()
- func (a *Allure) Init(parent *Allure, options ...plugin.Option)
- func (a *Allure) Known()
- func (a *Allure) Labels(labels ...Label)
- func (a *Allure) Links(links ...Link)
- func (a *Allure) Muted()
- func (a *Allure) Owner(owner string)
- func (a *Allure) Parameters(parameters ...Parameter)
- func (a *Allure) Plugin() plugin.Spec
- func (a *Allure) Severity(severity Severity)
- func (a *Allure) Story(story string)
- func (a *Allure) Tags(tags ...string)
- func (a *Allure) Title(title string)
- func (a *Allure) Titlef(format string, args ...any)
- type Assertions
- func (x Assertions[T]) Condition(comp assert.Comparison, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) DirExists(path string, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) ElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) Empty(object interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) EqualError(theError error, errString string, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) EqualExportedValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) Error(err error, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) ErrorAs(err error, target interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) ErrorContains(theError error, contains string, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) ErrorIs(err error, target error, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, ...) bool
- func (x Assertions[T]) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) False(value bool, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) FileExists(path string, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) GreaterOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, ...) bool
- func (x Assertions[T]) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, ...) bool
- func (x Assertions[T]) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, ...) bool
- func (x Assertions[T]) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, ...) bool
- func (x Assertions[T]) HTTPStatusCode(handler http.HandlerFunc, method string, url string, values url.Values, ...) bool
- func (x Assertions[T]) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, ...) bool
- func (a Assertions[T]) Hidden() Assertions[T]
- func (x Assertions[T]) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) InDelta(expected interface{}, actual interface{}, delta float64, ...) bool
- func (x Assertions[T]) InDeltaMapValues(expected interface{}, actual interface{}, delta float64, ...) bool
- func (x Assertions[T]) InDeltaSlice(expected interface{}, actual interface{}, delta float64, ...) bool
- func (x Assertions[T]) InEpsilon(expected interface{}, actual interface{}, epsilon float64, ...) bool
- func (x Assertions[T]) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, ...) bool
- func (x Assertions[T]) IsDecreasing(object interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) IsIncreasing(object interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) IsNonDecreasing(object interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) IsNonIncreasing(object interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) JSONEq(expected string, actual string, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) Len(object interface{}, length int, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) Less(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) LessOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool
- func (a Assertions[T]) Masked() Assertions[T]
- func (x Assertions[T]) Negative(e interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) Never(condition func() bool, waitFor time.Duration, tick time.Duration, ...) bool
- func (x Assertions[T]) Nil(object interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) NoDirExists(path string, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) NoError(err error, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) NoFileExists(path string, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) NotElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) NotEmpty(object interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) NotEqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) NotErrorAs(err error, target interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) NotErrorIs(err error, target error, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) NotImplements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) NotNil(object interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) NotSame(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) NotZero(i interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) PanicsWithError(errString string, f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) PanicsWithValue(expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) Positive(e interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) Same(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) True(value bool, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, ...) bool
- func (x Assertions[T]) WithinRange(actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) YAMLEq(expected string, actual string, msgAndArgs ...interface{}) bool
- func (x Assertions[T]) Zero(i interface{}, msgAndArgs ...interface{}) bool
- type Attachment
- type AttachmentBytes
- type AttachmentPath
- type Category
- type CommonT
- type Interface
- type Label
- type Link
- type LinkTransformerFunc
- type LinkType
- type MediaType
- type Parameter
- type ParameterMode
- type Requirements
- func (x Requirements[T]) Condition(comp assert.Comparison, msgAndArgs ...interface{})
- func (x Requirements[T]) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) DirExists(path string, msgAndArgs ...interface{})
- func (x Requirements[T]) ElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) Empty(object interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) EqualError(theError error, errString string, msgAndArgs ...interface{})
- func (x Requirements[T]) EqualExportedValues(expected interface{}, actual interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) Error(err error, msgAndArgs ...interface{})
- func (x Requirements[T]) ErrorAs(err error, target interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) ErrorContains(theError error, contains string, msgAndArgs ...interface{})
- func (x Requirements[T]) ErrorIs(err error, target error, msgAndArgs ...interface{})
- func (x Requirements[T]) Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, ...)
- func (x Requirements[T]) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) False(value bool, msgAndArgs ...interface{})
- func (x Requirements[T]) FileExists(path string, msgAndArgs ...interface{})
- func (x Requirements[T]) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) GreaterOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, ...)
- func (x Requirements[T]) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, ...)
- func (x Requirements[T]) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, ...)
- func (x Requirements[T]) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, ...)
- func (x Requirements[T]) HTTPStatusCode(handler http.HandlerFunc, method string, url string, values url.Values, ...)
- func (x Requirements[T]) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, ...)
- func (r Requirements[T]) Hidden() Requirements[T]
- func (x Requirements[T]) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) InDelta(expected interface{}, actual interface{}, delta float64, ...)
- func (x Requirements[T]) InDeltaMapValues(expected interface{}, actual interface{}, delta float64, ...)
- func (x Requirements[T]) InDeltaSlice(expected interface{}, actual interface{}, delta float64, ...)
- func (x Requirements[T]) InEpsilon(expected interface{}, actual interface{}, epsilon float64, ...)
- func (x Requirements[T]) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, ...)
- func (x Requirements[T]) IsDecreasing(object interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) IsIncreasing(object interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) IsNonDecreasing(object interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) IsNonIncreasing(object interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) JSONEq(expected string, actual string, msgAndArgs ...interface{})
- func (x Requirements[T]) Len(object interface{}, length int, msgAndArgs ...interface{})
- func (x Requirements[T]) Less(e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) LessOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
- func (r Requirements[T]) Masked() Requirements[T]
- func (x Requirements[T]) Negative(e interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) Never(condition func() bool, waitFor time.Duration, tick time.Duration, ...)
- func (x Requirements[T]) Nil(object interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) NoDirExists(path string, msgAndArgs ...interface{})
- func (x Requirements[T]) NoError(err error, msgAndArgs ...interface{})
- func (x Requirements[T]) NoFileExists(path string, msgAndArgs ...interface{})
- func (x Requirements[T]) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) NotElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) NotEmpty(object interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) NotEqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) NotErrorAs(err error, target interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) NotErrorIs(err error, target error, msgAndArgs ...interface{})
- func (x Requirements[T]) NotImplements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) NotNil(object interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{})
- func (x Requirements[T]) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) NotSame(expected interface{}, actual interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) NotZero(i interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{})
- func (x Requirements[T]) PanicsWithError(errString string, f assert.PanicTestFunc, msgAndArgs ...interface{})
- func (x Requirements[T]) PanicsWithValue(expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{})
- func (x Requirements[T]) Positive(e interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) Same(expected interface{}, actual interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{})
- func (x Requirements[T]) True(value bool, msgAndArgs ...interface{})
- func (x Requirements[T]) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, ...)
- func (x Requirements[T]) WithinRange(actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{})
- func (x Requirements[T]) YAMLEq(expected string, actual string, msgAndArgs ...interface{})
- func (x Requirements[T]) Zero(i interface{}, msgAndArgs ...interface{})
- type Severity
- type Status
- type StatusDetails
- type TitleFunc
- type UUID
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Setup ¶
Setup runs a Step marked as Setup in Allure report.
You may want to use it in BeforeEach, BeforeAll hooks.
See also TearDown.
func Step ¶
Step is similar to testo.Run, but if the step fails with fatal error, outer test execution will stop.
func TearDown ¶
TearDown runs a Step marked as TearDown in Allure report.
You may want to use it in AfterEach, AfterAll hooks.
See also Setup.
func WithCategories ¶
WithCategories adds custom categories to the report. This option should be passed to the top-level testo.RunSuite call.
func WithDefaultTitle ¶
WithDefaultTitle specifies a function used for setting a default title for each test and sub-test. If test sets a title for itself using Allure.Title, the result of this function is ignored.
func WithGroupParametrized ¶
WithGroupParametrized will enable grouping of parametrized tests.
Grouped tests will appear as steps under a single test named after their test function.
Allure only supports the following metadata for steps:
- Title
- Parameters
- Attachments
func WithLinkTransformer ¶
func WithLinkTransformer(f LinkTransformerFunc) plugin.Option
WithLinkTransformer specifies a function for transforming links before writing the report.
For example, may be useful to support short identifiers of issues and TMS links and use URL templates to generate full URLs.
func WithOutputDir ¶
WithOutputDir sets output directory for test results.
By default, it is "allure-results".
Types ¶
type Allure ¶
Allure defines allure plugin.
func (*Allure) Attach ¶
func (a *Allure) Attach(name string, attachment Attachment)
Attach an attachment.
See NewAttachmentBytes and NewAttachmentPath to create an attachment.
func (*Allure) Description ¶
Description sets an arbitrary text describing the test in more details than the title could fit.
The description will be treated as a Markdown text, so you can you some basic formatting in it. HTML tags are not allowed in such a text and will be removed when building the report.
func (*Allure) Descriptionf ¶
Descriptionf is the same as Allure.Description but uses fmt.Sprintf to set a description.
func (*Allure) Flaky ¶
func (a *Allure) Flaky()
Flaky indicates that this test or step is known to be unstable and can may not succeed every time.
func (*Allure) Known ¶
func (a *Allure) Known()
Known indicates that the test fails because of a known bug.
func (*Allure) Labels ¶
Labels adds given labels to the test result.
A test result can have multiple labels with the same name. For example, this is often the case when a test result has multiple tags.
Consider using helper methods such as Allure.Tags or Allure.Severity instead of using labels directly.
func (*Allure) Links ¶
Links adds a list of links to webpages that may be useful for a reader investigating a test failure. You can provide as many links as needed.
There are three types of links:
- a standard web link, e.g., a link to the description of the feature being tested;
- a link to an issue in the product's issue tracker;
- a link to the test description in a test management system (TMS).
func (*Allure) Muted ¶
func (a *Allure) Muted()
Muted indicates that the result must not affect the statistics.
func (*Allure) Owner ¶
Owner sets the team member who is responsible for the test's stability. For example, this can be the test's author, the leading developer of the feature being tested, etc.
func (*Allure) Parameters ¶
Parameters adds parameters to show for this report in the result.
func (*Allure) Severity ¶
Severity sets a value indicating how important the test is. This may give the future reader an idea of how to prioritize the investigations of different test failures.
func (*Allure) Tags ¶
Tags adds short terms the test is related to. Usually it's a good idea to list relevant features that are being tested.
Tags can then be used for filtering.
func (*Allure) Title ¶
Title sets a human-readable title of the test.
If not provided, function or subtest name is used instead.
func (*Allure) Titlef ¶
Titlef is the same as Allure.Title but uses fmt.Sprintf to set a title.
type Assertions ¶
type Assertions[T CommonT] struct { // contains filtered or unexported fields }
Assertions provides a set of helpers to perform assertions in tests.
Each assertion is included in the Allure report as a step with passed parameters.
func (Assertions[T]) Condition ¶
func (x Assertions[T]) Condition(comp assert.Comparison, msgAndArgs ...interface{}) bool
Condition uses a Comparison to assert a complex condition.
func (Assertions[T]) Contains ¶
func (x Assertions[T]) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool
Contains asserts that the specified string, list(array, slice...) or map contains the specified substring or element.
assert.Contains(t, "Hello World", "World")
assert.Contains(t, ["Hello", "World"], "World")
assert.Contains(t, {"Hello": "World"}, "Hello")
func (Assertions[T]) DirExists ¶
func (x Assertions[T]) DirExists(path string, msgAndArgs ...interface{}) bool
DirExists checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists.
func (Assertions[T]) ElementsMatch ¶
func (x Assertions[T]) ElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) bool
ElementsMatch asserts that the specified listA(array, slice...) is equal to specified listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, the number of appearances of each of them in both lists should match.
assert.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2])
func (Assertions[T]) Empty ¶
func (x Assertions[T]) Empty(object interface{}, msgAndArgs ...interface{}) bool
Empty asserts that the given value is "empty".
Zero values are "empty".
Arrays are "empty" if every element is the zero value of the type (stricter than "empty").
Slices, maps and channels with zero length are "empty".
Pointer values are "empty" if the pointer is nil or if the pointed value is "empty".
assert.Empty(t, obj)
func (Assertions[T]) Equal ¶
func (x Assertions[T]) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
Equal asserts that two objects are equal.
assert.Equal(t, 123, 123)
Pointer variable equality is determined based on the equality of the referenced values (as opposed to the memory addresses). Function equality cannot be determined and will always fail.
func (Assertions[T]) EqualError ¶
func (x Assertions[T]) EqualError(theError error, errString string, msgAndArgs ...interface{}) bool
EqualError asserts that a function returned an error (i.e. not `nil`) and that it is equal to the provided error.
actualObj, err := SomeFunction() assert.EqualError(t, err, expectedErrorString)
func (Assertions[T]) EqualExportedValues ¶
func (x Assertions[T]) EqualExportedValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
EqualExportedValues asserts that the types of two objects are equal and their public fields are also equal. This is useful for comparing structs that have private fields that could potentially differ.
type S struct {
Exported int
notExported int
}
assert.EqualExportedValues(t, S{1, 2}, S{1, 3}) => true
assert.EqualExportedValues(t, S{1, 2}, S{2, 3}) => false
func (Assertions[T]) EqualValues ¶
func (x Assertions[T]) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
EqualValues asserts that two objects are equal or convertible to the larger type and equal.
assert.EqualValues(t, uint32(123), int32(123))
func (Assertions[T]) Error ¶
func (x Assertions[T]) Error(err error, msgAndArgs ...interface{}) bool
Error asserts that a function returned an error (i.e. not `nil`).
actualObj, err := SomeFunction() assert.Error(t, err)
func (Assertions[T]) ErrorAs ¶
func (x Assertions[T]) ErrorAs(err error, target interface{}, msgAndArgs ...interface{}) bool
ErrorAs asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value. This is a wrapper for errors.As.
func (Assertions[T]) ErrorContains ¶
func (x Assertions[T]) ErrorContains(theError error, contains string, msgAndArgs ...interface{}) bool
ErrorContains asserts that a function returned an error (i.e. not `nil`) and that the error contains the specified substring.
actualObj, err := SomeFunction() assert.ErrorContains(t, err, expectedErrorSubString)
func (Assertions[T]) ErrorIs ¶
func (x Assertions[T]) ErrorIs(err error, target error, msgAndArgs ...interface{}) bool
ErrorIs asserts that at least one of the errors in err's chain matches target. This is a wrapper for errors.Is.
func (Assertions[T]) Eventually ¶
func (x Assertions[T]) Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool
Eventually asserts that given condition will be met in waitFor time, periodically checking target function each tick.
assert.Eventually(t, func() bool { return true; }, time.Second, 10*time.Millisecond)
func (Assertions[T]) Exactly ¶
func (x Assertions[T]) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
Exactly asserts that two objects are equal in value and type.
assert.Exactly(t, int32(123), int64(123))
func (Assertions[T]) False ¶
func (x Assertions[T]) False(value bool, msgAndArgs ...interface{}) bool
False asserts that the specified value is false.
assert.False(t, myBool)
func (Assertions[T]) FileExists ¶
func (x Assertions[T]) FileExists(path string, msgAndArgs ...interface{}) bool
FileExists checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file.
func (Assertions[T]) Greater ¶
func (x Assertions[T]) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool
Greater asserts that the first element is greater than the second
assert.Greater(t, 2, 1) assert.Greater(t, float64(2), float64(1)) assert.Greater(t, "b", "a")
func (Assertions[T]) GreaterOrEqual ¶
func (x Assertions[T]) GreaterOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool
GreaterOrEqual asserts that the first element is greater than or equal to the second
assert.GreaterOrEqual(t, 2, 1) assert.GreaterOrEqual(t, 2, 2) assert.GreaterOrEqual(t, "b", "a") assert.GreaterOrEqual(t, "b", "b")
func (Assertions[T]) HTTPBodyContains ¶
func (x Assertions[T]) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool
HTTPBodyContains asserts that a specified handler returns a body that contains a string.
assert.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
Returns whether the assertion was successful (true) or not (false).
func (Assertions[T]) HTTPBodyNotContains ¶
func (x Assertions[T]) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool
HTTPBodyNotContains asserts that a specified handler returns a body that does not contain a string.
assert.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
Returns whether the assertion was successful (true) or not (false).
func (Assertions[T]) HTTPError ¶
func (x Assertions[T]) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool
HTTPError asserts that a specified handler returns an error status code.
assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
Returns whether the assertion was successful (true) or not (false).
func (Assertions[T]) HTTPRedirect ¶
func (x Assertions[T]) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool
HTTPRedirect asserts that a specified handler returns a redirect status code.
assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
Returns whether the assertion was successful (true) or not (false).
func (Assertions[T]) HTTPStatusCode ¶
func (x Assertions[T]) HTTPStatusCode(handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msgAndArgs ...interface{}) bool
HTTPStatusCode asserts that a specified handler returns a specified status code.
assert.HTTPStatusCode(t, myHandler, "GET", "/notImplemented", nil, 501)
Returns whether the assertion was successful (true) or not (false).
func (Assertions[T]) HTTPSuccess ¶
func (x Assertions[T]) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool
HTTPSuccess asserts that a specified handler returns a success status code.
assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil)
Returns whether the assertion was successful (true) or not (false).
func (Assertions[T]) Hidden ¶
func (a Assertions[T]) Hidden() Assertions[T]
Hidden returns a new assertions instance which will hide its parameters.
func (Assertions[T]) Implements ¶
func (x Assertions[T]) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool
Implements asserts that an object is implemented by the specified interface.
assert.Implements(t, (*MyInterface)(nil), new(MyObject))
func (Assertions[T]) InDelta ¶
func (x Assertions[T]) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool
InDelta asserts that the two numerals are within delta of each other.
assert.InDelta(t, math.Pi, 22/7.0, 0.01)
func (Assertions[T]) InDeltaMapValues ¶
func (x Assertions[T]) InDeltaMapValues(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool
InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
func (Assertions[T]) InDeltaSlice ¶
func (x Assertions[T]) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool
InDeltaSlice is the same as InDelta, except it compares two slices.
func (Assertions[T]) InEpsilon ¶
func (x Assertions[T]) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool
InEpsilon asserts that expected and actual have a relative error less than epsilon
func (Assertions[T]) InEpsilonSlice ¶
func (x Assertions[T]) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool
InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
func (Assertions[T]) IsDecreasing ¶
func (x Assertions[T]) IsDecreasing(object interface{}, msgAndArgs ...interface{}) bool
IsDecreasing asserts that the collection is decreasing
assert.IsDecreasing(t, []int{2, 1, 0})
assert.IsDecreasing(t, []float{2, 1})
assert.IsDecreasing(t, []string{"b", "a"})
func (Assertions[T]) IsIncreasing ¶
func (x Assertions[T]) IsIncreasing(object interface{}, msgAndArgs ...interface{}) bool
IsIncreasing asserts that the collection is increasing
assert.IsIncreasing(t, []int{1, 2, 3})
assert.IsIncreasing(t, []float{1, 2})
assert.IsIncreasing(t, []string{"a", "b"})
func (Assertions[T]) IsNonDecreasing ¶
func (x Assertions[T]) IsNonDecreasing(object interface{}, msgAndArgs ...interface{}) bool
IsNonDecreasing asserts that the collection is not decreasing
assert.IsNonDecreasing(t, []int{1, 1, 2})
assert.IsNonDecreasing(t, []float{1, 2})
assert.IsNonDecreasing(t, []string{"a", "b"})
func (Assertions[T]) IsNonIncreasing ¶
func (x Assertions[T]) IsNonIncreasing(object interface{}, msgAndArgs ...interface{}) bool
IsNonIncreasing asserts that the collection is not increasing
assert.IsNonIncreasing(t, []int{2, 1, 1})
assert.IsNonIncreasing(t, []float{2, 1})
assert.IsNonIncreasing(t, []string{"b", "a"})
func (Assertions[T]) IsType ¶
func (x Assertions[T]) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool
IsType asserts that the specified objects are of the same type.
assert.IsType(t, &MyStruct{}, &MyStruct{})
func (Assertions[T]) JSONEq ¶
func (x Assertions[T]) JSONEq(expected string, actual string, msgAndArgs ...interface{}) bool
JSONEq asserts that two JSON strings are equivalent.
assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
func (Assertions[T]) Len ¶
func (x Assertions[T]) Len(object interface{}, length int, msgAndArgs ...interface{}) bool
Len asserts that the specified object has specific length. Len also fails if the object has a type that len() not accept.
assert.Len(t, mySlice, 3)
func (Assertions[T]) Less ¶
func (x Assertions[T]) Less(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool
Less asserts that the first element is less than the second
assert.Less(t, 1, 2) assert.Less(t, float64(1), float64(2)) assert.Less(t, "a", "b")
func (Assertions[T]) LessOrEqual ¶
func (x Assertions[T]) LessOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool
LessOrEqual asserts that the first element is less than or equal to the second
assert.LessOrEqual(t, 1, 2) assert.LessOrEqual(t, 2, 2) assert.LessOrEqual(t, "a", "b") assert.LessOrEqual(t, "b", "b")
func (Assertions[T]) Masked ¶
func (a Assertions[T]) Masked() Assertions[T]
Masked returns a new assertions instance which will mask its parameters.
func (Assertions[T]) Negative ¶
func (x Assertions[T]) Negative(e interface{}, msgAndArgs ...interface{}) bool
Negative asserts that the specified element is negative
assert.Negative(t, -1) assert.Negative(t, -1.23)
func (Assertions[T]) Never ¶
func (x Assertions[T]) Never(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool
Never asserts that the given condition doesn't satisfy in waitFor time, periodically checking the target function each tick.
assert.Never(t, func() bool { return false; }, time.Second, 10*time.Millisecond)
func (Assertions[T]) Nil ¶
func (x Assertions[T]) Nil(object interface{}, msgAndArgs ...interface{}) bool
Nil asserts that the specified object is nil.
assert.Nil(t, err)
func (Assertions[T]) NoDirExists ¶
func (x Assertions[T]) NoDirExists(path string, msgAndArgs ...interface{}) bool
NoDirExists checks whether a directory does not exist in the given path. It fails if the path points to an existing _directory_ only.
func (Assertions[T]) NoError ¶
func (x Assertions[T]) NoError(err error, msgAndArgs ...interface{}) bool
NoError asserts that a function returned no error (i.e. `nil`).
actualObj, err := SomeFunction()
if assert.NoError(t, err) {
assert.Equal(t, expectedObj, actualObj)
}
func (Assertions[T]) NoFileExists ¶
func (x Assertions[T]) NoFileExists(path string, msgAndArgs ...interface{}) bool
NoFileExists checks whether a file does not exist in a given path. It fails if the path points to an existing _file_ only.
func (Assertions[T]) NotContains ¶
func (x Assertions[T]) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool
NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the specified substring or element.
assert.NotContains(t, "Hello World", "Earth")
assert.NotContains(t, ["Hello", "World"], "Earth")
assert.NotContains(t, {"Hello": "World"}, "Earth")
func (Assertions[T]) NotElementsMatch ¶
func (x Assertions[T]) NotElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) bool
NotElementsMatch asserts that the specified listA(array, slice...) is NOT equal to specified listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, the number of appearances of each of them in both lists should not match. This is an inverse of ElementsMatch.
assert.NotElementsMatch(t, [1, 1, 2, 3], [1, 1, 2, 3]) -> false
assert.NotElementsMatch(t, [1, 1, 2, 3], [1, 2, 3]) -> true
assert.NotElementsMatch(t, [1, 2, 3], [1, 2, 4]) -> true
func (Assertions[T]) NotEmpty ¶
func (x Assertions[T]) NotEmpty(object interface{}, msgAndArgs ...interface{}) bool
NotEmpty asserts that the specified object is NOT [Empty].
if assert.NotEmpty(t, obj) {
assert.Equal(t, "two", obj[1])
}
func (Assertions[T]) NotEqual ¶
func (x Assertions[T]) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
NotEqual asserts that the specified values are NOT equal.
assert.NotEqual(t, obj1, obj2)
Pointer variable equality is determined based on the equality of the referenced values (as opposed to the memory addresses).
func (Assertions[T]) NotEqualValues ¶
func (x Assertions[T]) NotEqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
NotEqualValues asserts that two objects are not equal even when converted to the same type
assert.NotEqualValues(t, obj1, obj2)
func (Assertions[T]) NotErrorAs ¶
func (x Assertions[T]) NotErrorAs(err error, target interface{}, msgAndArgs ...interface{}) bool
NotErrorAs asserts that none of the errors in err's chain matches target, but if so, sets target to that error value.
func (Assertions[T]) NotErrorIs ¶
func (x Assertions[T]) NotErrorIs(err error, target error, msgAndArgs ...interface{}) bool
NotErrorIs asserts that none of the errors in err's chain matches target. This is a wrapper for errors.Is.
func (Assertions[T]) NotImplements ¶
func (x Assertions[T]) NotImplements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool
NotImplements asserts that an object does not implement the specified interface.
assert.NotImplements(t, (*MyInterface)(nil), new(MyObject))
func (Assertions[T]) NotNil ¶
func (x Assertions[T]) NotNil(object interface{}, msgAndArgs ...interface{}) bool
NotNil asserts that the specified object is not nil.
assert.NotNil(t, err)
func (Assertions[T]) NotPanics ¶
func (x Assertions[T]) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
assert.NotPanics(t, func(){ RemainCalm() })
func (Assertions[T]) NotRegexp ¶
func (x Assertions[T]) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool
NotRegexp asserts that a specified regexp does not match a string.
assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting")
assert.NotRegexp(t, "^start", "it's not starting")
func (Assertions[T]) NotSame ¶
func (x Assertions[T]) NotSame(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
NotSame asserts that two pointers do not reference the same object.
assert.NotSame(t, ptr1, ptr2)
Both arguments must be pointer variables. Pointer variable sameness is determined based on the equality of both type and value.
func (Assertions[T]) NotSubset ¶
func (x Assertions[T]) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool
NotSubset asserts that the list (array, slice, or map) does NOT contain all elements given in the subset (array, slice, or map). Map elements are key-value pairs unless compared with an array or slice where only the map key is evaluated.
assert.NotSubset(t, [1, 3, 4], [1, 2])
assert.NotSubset(t, {"x": 1, "y": 2}, {"z": 3})
assert.NotSubset(t, [1, 3, 4], {1: "one", 2: "two"})
assert.NotSubset(t, {"x": 1, "y": 2}, ["z"])
func (Assertions[T]) NotZero ¶
func (x Assertions[T]) NotZero(i interface{}, msgAndArgs ...interface{}) bool
NotZero asserts that i is not the zero value for its type.
func (Assertions[T]) Panics ¶
func (x Assertions[T]) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
Panics asserts that the code inside the specified PanicTestFunc panics.
assert.Panics(t, func(){ GoCrazy() })
func (Assertions[T]) PanicsWithError ¶
func (x Assertions[T]) PanicsWithError(errString string, f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
PanicsWithError asserts that the code inside the specified PanicTestFunc panics, and that the recovered panic value is an error that satisfies the EqualError comparison.
assert.PanicsWithError(t, "crazy error", func(){ GoCrazy() })
func (Assertions[T]) PanicsWithValue ¶
func (x Assertions[T]) PanicsWithValue(expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that the recovered panic value equals the expected panic value.
assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() })
func (Assertions[T]) Positive ¶
func (x Assertions[T]) Positive(e interface{}, msgAndArgs ...interface{}) bool
Positive asserts that the specified element is positive
assert.Positive(t, 1) assert.Positive(t, 1.23)
func (Assertions[T]) Regexp ¶
func (x Assertions[T]) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool
Regexp asserts that a specified regexp matches a string.
assert.Regexp(t, regexp.MustCompile("start"), "it's starting")
assert.Regexp(t, "start...$", "it's not starting")
func (Assertions[T]) Same ¶
func (x Assertions[T]) Same(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
Same asserts that two pointers reference the same object.
assert.Same(t, ptr1, ptr2)
Both arguments must be pointer variables. Pointer variable sameness is determined based on the equality of both type and value.
func (Assertions[T]) Subset ¶
func (x Assertions[T]) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool
Subset asserts that the list (array, slice, or map) contains all elements given in the subset (array, slice, or map). Map elements are key-value pairs unless compared with an array or slice where only the map key is evaluated.
assert.Subset(t, [1, 2, 3], [1, 2])
assert.Subset(t, {"x": 1, "y": 2}, {"x": 1})
assert.Subset(t, [1, 2, 3], {1: "one", 2: "two"})
assert.Subset(t, {"x": 1, "y": 2}, ["x"])
func (Assertions[T]) True ¶
func (x Assertions[T]) True(value bool, msgAndArgs ...interface{}) bool
True asserts that the specified value is true.
assert.True(t, myBool)
func (Assertions[T]) WithinDuration ¶
func (x Assertions[T]) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool
WithinDuration asserts that the two times are within duration delta of each other.
assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second)
func (Assertions[T]) WithinRange ¶
func (x Assertions[T]) WithinRange(actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) bool
WithinRange asserts that a time is within a time range (inclusive).
assert.WithinRange(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second))
func (Assertions[T]) YAMLEq ¶
func (x Assertions[T]) YAMLEq(expected string, actual string, msgAndArgs ...interface{}) bool
YAMLEq asserts that two YAML strings are equivalent.
func (Assertions[T]) Zero ¶
func (x Assertions[T]) Zero(i interface{}, msgAndArgs ...interface{}) bool
Zero asserts that i is the zero value for its type.
type Attachment ¶
type Attachment interface {
// Open attachment for reading.
Open() (io.ReadCloser, error)
// UUID returns the unique id of this attachment.
UUID() UUID
// Type returns the media type of the content.
Type() MediaType
}
Attachment to add into report.
See Allure attachments for more information.
type AttachmentBytes ¶
type AttachmentBytes struct {
// contains filtered or unexported fields
}
AttachmentBytes is an attachment which stores its contents in-memory. Consider using AttachmentPath for large files.
func NewAttachmentBytes ¶
func NewAttachmentBytes(data []byte) AttachmentBytes
NewAttachmentBytes creates a new bytes attachment from the given bytes.
See AttachmentBytes.As to specify media type to enable preview in Allure report.
Example ¶
a := NewAttachmentBytes(
[]byte(`{"name": "value"}`),
).As(DocumentJSON)
fmt.Println(a.Type())
Output: application/json
func NewAttachmentString ¶
func NewAttachmentString(data string) AttachmentBytes
NewAttachmentString creates a new bytes attachment from the given string and sets media type to TextPlain.
func (AttachmentBytes) As ¶
func (b AttachmentBytes) As(mediaType MediaType) AttachmentBytes
As returns new attachment with the given media type.
func (AttachmentBytes) Open ¶
func (b AttachmentBytes) Open() (io.ReadCloser, error)
Open attachment for reading.
func (AttachmentBytes) Type ¶
func (b AttachmentBytes) Type() MediaType
Type returns the media type of the content.
func (AttachmentBytes) UUID ¶
func (b AttachmentBytes) UUID() UUID
UUID returns the unique id of this attachment.
type AttachmentPath ¶
type AttachmentPath struct {
// contains filtered or unexported fields
}
AttachmentPath is an attachment stored in the file located at path.
func NewAttachmentPath ¶
func NewAttachmentPath(path string) AttachmentPath
NewAttachmentPath creates a new attachment from the given file path. Note that file at path won't be read until all suite tests are finished (in AfterAll hook). Use AttachmentPath.Read method to convert it to AttachmentBytes.
func (AttachmentPath) MustRead ¶
func (p AttachmentPath) MustRead() AttachmentBytes
MustRead reads the file at path and return it as AttachmentBytes. Panics on error.
See also AttachmentPath.Read for non-panicking version.
func (AttachmentPath) Open ¶
func (p AttachmentPath) Open() (io.ReadCloser, error)
Open attachment for reading.
func (AttachmentPath) Read ¶
func (p AttachmentPath) Read() (AttachmentBytes, error)
Read the file at path and return it as AttachmentBytes. Error is returned if reading a file failed.
See also AttachmentPath.MustRead.
func (AttachmentPath) Type ¶
func (p AttachmentPath) Type() MediaType
Type returns the media type of the content.
func (AttachmentPath) UUID ¶
func (p AttachmentPath) UUID() UUID
UUID returns the unique id of this attachment.
type Category ¶
type Category struct {
// Name of the category.
Name string `json:"name"`
// MessageRegex is the regular expression
// that the test result's message should match.
MessageRegex string `json:"messageRegex"`
// TraceRegex is the regular expression that
// the test result's trace should match.
TraceRegex string `json:"traceRegex"`
// MatchedStatuses are the statuses that
// the test result should be one of.
MatchedStatuses []Status `json:"matchedStatuses"`
}
Category defines tests category.
Allure checks each test against all the categories in the file, from top to bottom. The test gets assigned the first matching category. When no matches are found, Allure uses one of the default categories if the test is unsuccessful or no category otherwise.
type Interface ¶
type Interface interface {
// Title sets a human-readable title of the test.
//
// If not provided, function or subtest name is used instead.
Title(title string)
// Titlef is the same as [Allure.Title] but
// uses [fmt.Sprintf] to set a title.
Titlef(format string, args ...any)
// Description sets an arbitrary text describing the test in
// more details than the title could fit.
//
// The description will be treated as a Markdown text,
// so you can you some basic formatting in it.
// HTML tags are not allowed in such a text and will
// be removed when building the report.
Description(desc string)
// Descriptionf is the same as [Allure.Description] but
// uses [fmt.Sprintf] to set a description.
Descriptionf(format string, args ...any)
// Links adds a list of links to webpages that may be useful for a reader investigating a test failure.
// You can provide as many links as needed.
//
// There are three types of links:
// - a standard web link, e.g., a link to the description of the feature being tested;
// - a link to an issue in the product's issue tracker;
// - a link to the test description in a test management system (TMS).
Links(links ...Link)
// Labels adds given labels to the test result.
//
// A test result can have multiple labels with the same name.
// For example, this is often the case when a test result has multiple tags.
//
// Consider using helper methods such as [Allure.Tags] or [Allure.Severity]
// instead of using labels directly.
Labels(labels ...Label)
// Tags adds short terms the test is related to.
// Usually it's a good idea to list relevant
// features that are being tested.
//
// Tags can then be used for [filtering].
//
// [filtering]: https://allurereport.org/docs/sorting-and-filtering/#filter-tests-by-tags
Tags(tags ...string)
// Parameters adds parameters to show for this report in the result.
Parameters(parameters ...Parameter)
// Owner sets the team member who is responsible for the test's stability.
// For example, this can be the test's author, the
// leading developer of the feature being tested, etc.
Owner(owner string)
// Severity sets a value indicating how important the test is.
// This may give the future reader an idea of how
// to prioritize the investigations of different test failures.
Severity(severity Severity)
// Epic linked to this test.
Epic(epic string)
// Feature linked to this test.
Feature(feature string)
// Story linked to this test.
Story(story string)
// Flaky indicates that this test or step is known
// to be unstable and can may not succeed every time.
Flaky()
// Muted indicates that the result
// must not affect the statistics.
Muted()
// Known indicates that the test
// fails because of a known bug.
Known()
// Attach an attachment.
//
// See [NewAttachmentBytes] and [NewAttachmentPath] to create an attachment.
Attach(name string, attachment Attachment)
}
Interface defines allure plugin interface. Useful for writing helpers which require allure methods but can't rely on concrete type.
type Link ¶
Link to webpage that may be useful for a reader investigating a test failure.
func NewLinkf ¶
NewLinkf is the same as NewLink but uses fmt.Sprintf to format url.
type LinkTransformerFunc ¶
LinkTransformerFunc takes a raw link provided by the user and transforms it before writing the report.
type MediaType ¶
type MediaType string
MediaType stands for MIME type strings.
See also list of all official MIME types.
const ( ImagePNG MediaType = "image/png" ImageJPEG MediaType = "image/jpeg" ImageWEBP MediaType = "image/webp" ImageGIF MediaType = "image/gif" ImageSVG MediaType = "image/svg+xml" ImageTIFF MediaType = "image/tiff" ImageBMP MediaType = "image/bmp" )
Image types for attachments supported by Allure report.
See also screenshot attachments.
const ( VideoMP4 MediaType = "video/mp4" VideoOGG MediaType = "video/ogg" VideoWebM MediaType = "video/webm" )
Video types for attachments supported by Allure report.
See also video attachments.
Text types for attachments supported by Allure report.
See also text attachments.
Table types for attachments supported by Allure report.
See also table attachments.
const ( DocumentXML MediaType = "text/xml" DocumentJSON MediaType = "application/json" DocumentYAML MediaType = "application/yaml" )
Document types for attachments supported by Allure report.
See also document attachments.
const URIList MediaType = "text/uri-list"
URIList is uri list type for attachments.
See also uri lists attachments.
type Parameter ¶
type Parameter struct {
Name string `json:"name"`
Value string `json:"value"`
Excluded bool `json:"excluded"`
Mode ParameterMode `json:"mode"`
}
Parameter to show in the report.
Allure plugin automatically sets parameters for parametrized tests.
func NewParameter ¶
NewParameter constructs a new Parameter.
type ParameterMode ¶
type ParameterMode int
ParameterMode controls how the parameter will be shown in the report.
const ( // ParameterModeDefault - the parameter and its value // will be shown in a table along with other parameters. ParameterModeDefault ParameterMode = iota // ParameterModeMasked - the parameter will be shown // in the table, but its value will be hidden. ParameterModeMasked // ParameterModeHidden - the parameter and its value // will not be shown in the test report. ParameterModeHidden )
func (ParameterMode) MarshalText ¶
func (pm ParameterMode) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler.
func (ParameterMode) String ¶
func (pm ParameterMode) String() string
type Requirements ¶
type Requirements[T CommonT] struct { // contains filtered or unexported fields }
Requirements implements the same assertions as Assertions but stops test execution when assertion fails.
func Require ¶
func Require[T CommonT](t T) Requirements[T]
Require returns a new Requirements instance.
func (Requirements[T]) Condition ¶
func (x Requirements[T]) Condition(comp assert.Comparison, msgAndArgs ...interface{})
Condition uses a Comparison to assert a complex condition.
func (Requirements[T]) Contains ¶
func (x Requirements[T]) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{})
Contains asserts that the specified string, list(array, slice...) or map contains the specified substring or element.
assert.Contains(t, "Hello World", "World")
assert.Contains(t, ["Hello", "World"], "World")
assert.Contains(t, {"Hello": "World"}, "Hello")
func (Requirements[T]) DirExists ¶
func (x Requirements[T]) DirExists(path string, msgAndArgs ...interface{})
DirExists checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists.
func (Requirements[T]) ElementsMatch ¶
func (x Requirements[T]) ElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{})
ElementsMatch asserts that the specified listA(array, slice...) is equal to specified listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, the number of appearances of each of them in both lists should match.
assert.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2])
func (Requirements[T]) Empty ¶
func (x Requirements[T]) Empty(object interface{}, msgAndArgs ...interface{})
Empty asserts that the given value is "empty".
Zero values are "empty".
Arrays are "empty" if every element is the zero value of the type (stricter than "empty").
Slices, maps and channels with zero length are "empty".
Pointer values are "empty" if the pointer is nil or if the pointed value is "empty".
assert.Empty(t, obj)
func (Requirements[T]) Equal ¶
func (x Requirements[T]) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{})
Equal asserts that two objects are equal.
assert.Equal(t, 123, 123)
Pointer variable equality is determined based on the equality of the referenced values (as opposed to the memory addresses). Function equality cannot be determined and will always fail.
func (Requirements[T]) EqualError ¶
func (x Requirements[T]) EqualError(theError error, errString string, msgAndArgs ...interface{})
EqualError asserts that a function returned an error (i.e. not `nil`) and that it is equal to the provided error.
actualObj, err := SomeFunction() assert.EqualError(t, err, expectedErrorString)
func (Requirements[T]) EqualExportedValues ¶
func (x Requirements[T]) EqualExportedValues(expected interface{}, actual interface{}, msgAndArgs ...interface{})
EqualExportedValues asserts that the types of two objects are equal and their public fields are also equal. This is useful for comparing structs that have private fields that could potentially differ.
type S struct {
Exported int
notExported int
}
assert.EqualExportedValues(t, S{1, 2}, S{1, 3}) => true
assert.EqualExportedValues(t, S{1, 2}, S{2, 3}) => false
func (Requirements[T]) EqualValues ¶
func (x Requirements[T]) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{})
EqualValues asserts that two objects are equal or convertible to the larger type and equal.
assert.EqualValues(t, uint32(123), int32(123))
func (Requirements[T]) Error ¶
func (x Requirements[T]) Error(err error, msgAndArgs ...interface{})
Error asserts that a function returned an error (i.e. not `nil`).
actualObj, err := SomeFunction() assert.Error(t, err)
func (Requirements[T]) ErrorAs ¶
func (x Requirements[T]) ErrorAs(err error, target interface{}, msgAndArgs ...interface{})
ErrorAs asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value. This is a wrapper for errors.As.
func (Requirements[T]) ErrorContains ¶
func (x Requirements[T]) ErrorContains(theError error, contains string, msgAndArgs ...interface{})
ErrorContains asserts that a function returned an error (i.e. not `nil`) and that the error contains the specified substring.
actualObj, err := SomeFunction() assert.ErrorContains(t, err, expectedErrorSubString)
func (Requirements[T]) ErrorIs ¶
func (x Requirements[T]) ErrorIs(err error, target error, msgAndArgs ...interface{})
ErrorIs asserts that at least one of the errors in err's chain matches target. This is a wrapper for errors.Is.
func (Requirements[T]) Eventually ¶
func (x Requirements[T]) Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{})
Eventually asserts that given condition will be met in waitFor time, periodically checking target function each tick.
assert.Eventually(t, func() bool { return true; }, time.Second, 10*time.Millisecond)
func (Requirements[T]) Exactly ¶
func (x Requirements[T]) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{})
Exactly asserts that two objects are equal in value and type.
assert.Exactly(t, int32(123), int64(123))
func (Requirements[T]) False ¶
func (x Requirements[T]) False(value bool, msgAndArgs ...interface{})
False asserts that the specified value is false.
assert.False(t, myBool)
func (Requirements[T]) FileExists ¶
func (x Requirements[T]) FileExists(path string, msgAndArgs ...interface{})
FileExists checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file.
func (Requirements[T]) Greater ¶
func (x Requirements[T]) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
Greater asserts that the first element is greater than the second
assert.Greater(t, 2, 1) assert.Greater(t, float64(2), float64(1)) assert.Greater(t, "b", "a")
func (Requirements[T]) GreaterOrEqual ¶
func (x Requirements[T]) GreaterOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
GreaterOrEqual asserts that the first element is greater than or equal to the second
assert.GreaterOrEqual(t, 2, 1) assert.GreaterOrEqual(t, 2, 2) assert.GreaterOrEqual(t, "b", "a") assert.GreaterOrEqual(t, "b", "b")
func (Requirements[T]) HTTPBodyContains ¶
func (x Requirements[T]) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{})
HTTPBodyContains asserts that a specified handler returns a body that contains a string.
assert.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
Returns whether the assertion was successful (true) or not (false).
func (Requirements[T]) HTTPBodyNotContains ¶
func (x Requirements[T]) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{})
HTTPBodyNotContains asserts that a specified handler returns a body that does not contain a string.
assert.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
Returns whether the assertion was successful (true) or not (false).
func (Requirements[T]) HTTPError ¶
func (x Requirements[T]) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{})
HTTPError asserts that a specified handler returns an error status code.
assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
Returns whether the assertion was successful (true) or not (false).
func (Requirements[T]) HTTPRedirect ¶
func (x Requirements[T]) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{})
HTTPRedirect asserts that a specified handler returns a redirect status code.
assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
Returns whether the assertion was successful (true) or not (false).
func (Requirements[T]) HTTPStatusCode ¶
func (x Requirements[T]) HTTPStatusCode(handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msgAndArgs ...interface{})
HTTPStatusCode asserts that a specified handler returns a specified status code.
assert.HTTPStatusCode(t, myHandler, "GET", "/notImplemented", nil, 501)
Returns whether the assertion was successful (true) or not (false).
func (Requirements[T]) HTTPSuccess ¶
func (x Requirements[T]) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{})
HTTPSuccess asserts that a specified handler returns a success status code.
assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil)
Returns whether the assertion was successful (true) or not (false).
func (Requirements[T]) Hidden ¶
func (r Requirements[T]) Hidden() Requirements[T]
Hidden returns a new requirements instance which will hide its parameters.
func (Requirements[T]) Implements ¶
func (x Requirements[T]) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{})
Implements asserts that an object is implemented by the specified interface.
assert.Implements(t, (*MyInterface)(nil), new(MyObject))
func (Requirements[T]) InDelta ¶
func (x Requirements[T]) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{})
InDelta asserts that the two numerals are within delta of each other.
assert.InDelta(t, math.Pi, 22/7.0, 0.01)
func (Requirements[T]) InDeltaMapValues ¶
func (x Requirements[T]) InDeltaMapValues(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{})
InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
func (Requirements[T]) InDeltaSlice ¶
func (x Requirements[T]) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{})
InDeltaSlice is the same as InDelta, except it compares two slices.
func (Requirements[T]) InEpsilon ¶
func (x Requirements[T]) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{})
InEpsilon asserts that expected and actual have a relative error less than epsilon
func (Requirements[T]) InEpsilonSlice ¶
func (x Requirements[T]) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{})
InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
func (Requirements[T]) IsDecreasing ¶
func (x Requirements[T]) IsDecreasing(object interface{}, msgAndArgs ...interface{})
IsDecreasing asserts that the collection is decreasing
assert.IsDecreasing(t, []int{2, 1, 0})
assert.IsDecreasing(t, []float{2, 1})
assert.IsDecreasing(t, []string{"b", "a"})
func (Requirements[T]) IsIncreasing ¶
func (x Requirements[T]) IsIncreasing(object interface{}, msgAndArgs ...interface{})
IsIncreasing asserts that the collection is increasing
assert.IsIncreasing(t, []int{1, 2, 3})
assert.IsIncreasing(t, []float{1, 2})
assert.IsIncreasing(t, []string{"a", "b"})
func (Requirements[T]) IsNonDecreasing ¶
func (x Requirements[T]) IsNonDecreasing(object interface{}, msgAndArgs ...interface{})
IsNonDecreasing asserts that the collection is not decreasing
assert.IsNonDecreasing(t, []int{1, 1, 2})
assert.IsNonDecreasing(t, []float{1, 2})
assert.IsNonDecreasing(t, []string{"a", "b"})
func (Requirements[T]) IsNonIncreasing ¶
func (x Requirements[T]) IsNonIncreasing(object interface{}, msgAndArgs ...interface{})
IsNonIncreasing asserts that the collection is not increasing
assert.IsNonIncreasing(t, []int{2, 1, 1})
assert.IsNonIncreasing(t, []float{2, 1})
assert.IsNonIncreasing(t, []string{"b", "a"})
func (Requirements[T]) IsType ¶
func (x Requirements[T]) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{})
IsType asserts that the specified objects are of the same type.
assert.IsType(t, &MyStruct{}, &MyStruct{})
func (Requirements[T]) JSONEq ¶
func (x Requirements[T]) JSONEq(expected string, actual string, msgAndArgs ...interface{})
JSONEq asserts that two JSON strings are equivalent.
assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
func (Requirements[T]) Len ¶
func (x Requirements[T]) Len(object interface{}, length int, msgAndArgs ...interface{})
Len asserts that the specified object has specific length. Len also fails if the object has a type that len() not accept.
assert.Len(t, mySlice, 3)
func (Requirements[T]) Less ¶
func (x Requirements[T]) Less(e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
Less asserts that the first element is less than the second
assert.Less(t, 1, 2) assert.Less(t, float64(1), float64(2)) assert.Less(t, "a", "b")
func (Requirements[T]) LessOrEqual ¶
func (x Requirements[T]) LessOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
LessOrEqual asserts that the first element is less than or equal to the second
assert.LessOrEqual(t, 1, 2) assert.LessOrEqual(t, 2, 2) assert.LessOrEqual(t, "a", "b") assert.LessOrEqual(t, "b", "b")
func (Requirements[T]) Masked ¶
func (r Requirements[T]) Masked() Requirements[T]
Masked returns a new requirements instance which will mask its parameters.
func (Requirements[T]) Negative ¶
func (x Requirements[T]) Negative(e interface{}, msgAndArgs ...interface{})
Negative asserts that the specified element is negative
assert.Negative(t, -1) assert.Negative(t, -1.23)
func (Requirements[T]) Never ¶
func (x Requirements[T]) Never(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{})
Never asserts that the given condition doesn't satisfy in waitFor time, periodically checking the target function each tick.
assert.Never(t, func() bool { return false; }, time.Second, 10*time.Millisecond)
func (Requirements[T]) Nil ¶
func (x Requirements[T]) Nil(object interface{}, msgAndArgs ...interface{})
Nil asserts that the specified object is nil.
assert.Nil(t, err)
func (Requirements[T]) NoDirExists ¶
func (x Requirements[T]) NoDirExists(path string, msgAndArgs ...interface{})
NoDirExists checks whether a directory does not exist in the given path. It fails if the path points to an existing _directory_ only.
func (Requirements[T]) NoError ¶
func (x Requirements[T]) NoError(err error, msgAndArgs ...interface{})
NoError asserts that a function returned no error (i.e. `nil`).
actualObj, err := SomeFunction()
if assert.NoError(t, err) {
assert.Equal(t, expectedObj, actualObj)
}
func (Requirements[T]) NoFileExists ¶
func (x Requirements[T]) NoFileExists(path string, msgAndArgs ...interface{})
NoFileExists checks whether a file does not exist in a given path. It fails if the path points to an existing _file_ only.
func (Requirements[T]) NotContains ¶
func (x Requirements[T]) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{})
NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the specified substring or element.
assert.NotContains(t, "Hello World", "Earth")
assert.NotContains(t, ["Hello", "World"], "Earth")
assert.NotContains(t, {"Hello": "World"}, "Earth")
func (Requirements[T]) NotElementsMatch ¶
func (x Requirements[T]) NotElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{})
NotElementsMatch asserts that the specified listA(array, slice...) is NOT equal to specified listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, the number of appearances of each of them in both lists should not match. This is an inverse of ElementsMatch.
assert.NotElementsMatch(t, [1, 1, 2, 3], [1, 1, 2, 3]) -> false
assert.NotElementsMatch(t, [1, 1, 2, 3], [1, 2, 3]) -> true
assert.NotElementsMatch(t, [1, 2, 3], [1, 2, 4]) -> true
func (Requirements[T]) NotEmpty ¶
func (x Requirements[T]) NotEmpty(object interface{}, msgAndArgs ...interface{})
NotEmpty asserts that the specified object is NOT [Empty].
if assert.NotEmpty(t, obj) {
assert.Equal(t, "two", obj[1])
}
func (Requirements[T]) NotEqual ¶
func (x Requirements[T]) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{})
NotEqual asserts that the specified values are NOT equal.
assert.NotEqual(t, obj1, obj2)
Pointer variable equality is determined based on the equality of the referenced values (as opposed to the memory addresses).
func (Requirements[T]) NotEqualValues ¶
func (x Requirements[T]) NotEqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{})
NotEqualValues asserts that two objects are not equal even when converted to the same type
assert.NotEqualValues(t, obj1, obj2)
func (Requirements[T]) NotErrorAs ¶
func (x Requirements[T]) NotErrorAs(err error, target interface{}, msgAndArgs ...interface{})
NotErrorAs asserts that none of the errors in err's chain matches target, but if so, sets target to that error value.
func (Requirements[T]) NotErrorIs ¶
func (x Requirements[T]) NotErrorIs(err error, target error, msgAndArgs ...interface{})
NotErrorIs asserts that none of the errors in err's chain matches target. This is a wrapper for errors.Is.
func (Requirements[T]) NotImplements ¶
func (x Requirements[T]) NotImplements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{})
NotImplements asserts that an object does not implement the specified interface.
assert.NotImplements(t, (*MyInterface)(nil), new(MyObject))
func (Requirements[T]) NotNil ¶
func (x Requirements[T]) NotNil(object interface{}, msgAndArgs ...interface{})
NotNil asserts that the specified object is not nil.
assert.NotNil(t, err)
func (Requirements[T]) NotPanics ¶
func (x Requirements[T]) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{})
NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
assert.NotPanics(t, func(){ RemainCalm() })
func (Requirements[T]) NotRegexp ¶
func (x Requirements[T]) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{})
NotRegexp asserts that a specified regexp does not match a string.
assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting")
assert.NotRegexp(t, "^start", "it's not starting")
func (Requirements[T]) NotSame ¶
func (x Requirements[T]) NotSame(expected interface{}, actual interface{}, msgAndArgs ...interface{})
NotSame asserts that two pointers do not reference the same object.
assert.NotSame(t, ptr1, ptr2)
Both arguments must be pointer variables. Pointer variable sameness is determined based on the equality of both type and value.
func (Requirements[T]) NotSubset ¶
func (x Requirements[T]) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{})
NotSubset asserts that the list (array, slice, or map) does NOT contain all elements given in the subset (array, slice, or map). Map elements are key-value pairs unless compared with an array or slice where only the map key is evaluated.
assert.NotSubset(t, [1, 3, 4], [1, 2])
assert.NotSubset(t, {"x": 1, "y": 2}, {"z": 3})
assert.NotSubset(t, [1, 3, 4], {1: "one", 2: "two"})
assert.NotSubset(t, {"x": 1, "y": 2}, ["z"])
func (Requirements[T]) NotZero ¶
func (x Requirements[T]) NotZero(i interface{}, msgAndArgs ...interface{})
NotZero asserts that i is not the zero value for its type.
func (Requirements[T]) Panics ¶
func (x Requirements[T]) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{})
Panics asserts that the code inside the specified PanicTestFunc panics.
assert.Panics(t, func(){ GoCrazy() })
func (Requirements[T]) PanicsWithError ¶
func (x Requirements[T]) PanicsWithError(errString string, f assert.PanicTestFunc, msgAndArgs ...interface{})
PanicsWithError asserts that the code inside the specified PanicTestFunc panics, and that the recovered panic value is an error that satisfies the EqualError comparison.
assert.PanicsWithError(t, "crazy error", func(){ GoCrazy() })
func (Requirements[T]) PanicsWithValue ¶
func (x Requirements[T]) PanicsWithValue(expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{})
PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that the recovered panic value equals the expected panic value.
assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() })
func (Requirements[T]) Positive ¶
func (x Requirements[T]) Positive(e interface{}, msgAndArgs ...interface{})
Positive asserts that the specified element is positive
assert.Positive(t, 1) assert.Positive(t, 1.23)
func (Requirements[T]) Regexp ¶
func (x Requirements[T]) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{})
Regexp asserts that a specified regexp matches a string.
assert.Regexp(t, regexp.MustCompile("start"), "it's starting")
assert.Regexp(t, "start...$", "it's not starting")
func (Requirements[T]) Same ¶
func (x Requirements[T]) Same(expected interface{}, actual interface{}, msgAndArgs ...interface{})
Same asserts that two pointers reference the same object.
assert.Same(t, ptr1, ptr2)
Both arguments must be pointer variables. Pointer variable sameness is determined based on the equality of both type and value.
func (Requirements[T]) Subset ¶
func (x Requirements[T]) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{})
Subset asserts that the list (array, slice, or map) contains all elements given in the subset (array, slice, or map). Map elements are key-value pairs unless compared with an array or slice where only the map key is evaluated.
assert.Subset(t, [1, 2, 3], [1, 2])
assert.Subset(t, {"x": 1, "y": 2}, {"x": 1})
assert.Subset(t, [1, 2, 3], {1: "one", 2: "two"})
assert.Subset(t, {"x": 1, "y": 2}, ["x"])
func (Requirements[T]) True ¶
func (x Requirements[T]) True(value bool, msgAndArgs ...interface{})
True asserts that the specified value is true.
assert.True(t, myBool)
func (Requirements[T]) WithinDuration ¶
func (x Requirements[T]) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{})
WithinDuration asserts that the two times are within duration delta of each other.
assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second)
func (Requirements[T]) WithinRange ¶
func (x Requirements[T]) WithinRange(actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{})
WithinRange asserts that a time is within a time range (inclusive).
assert.WithinRange(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second))
func (Requirements[T]) YAMLEq ¶
func (x Requirements[T]) YAMLEq(expected string, actual string, msgAndArgs ...interface{})
YAMLEq asserts that two YAML strings are equivalent.
func (Requirements[T]) Zero ¶
func (x Requirements[T]) Zero(i interface{}, msgAndArgs ...interface{})
Zero asserts that i is the zero value for its type.
type Severity ¶
type Severity int
Severity is a value indicating how important the test is. This may give the future reader an idea of how to prioritize the investigations of different test failures.
const ( SeverityNormal Severity = iota SeverityTrivial SeverityMinor SeverityCritical SeverityBlocker )
Possible severity values.
func (Severity) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
type Status ¶
type Status int
Status is the test status.
Possible statuses.
func (Status) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
type StatusDetails ¶
type StatusDetails struct {
// Known indicates that the test
// fails because of a known bug.
Known bool `json:"known"`
// Muted indicates that the result
// must not affect the statistics.
Muted bool `json:"muted"`
// Flaky indicates that this test or step is known
// to be unstable and can may not succeed every time.
Flaky bool `json:"flaky"`
// Message is the short text message to display in the
// test details, such as a name of the exception that led to a failure.
Message string `json:"message"`
// Trace is the full stack trace to display in the test details.
Trace string `json:"trace"`
}
StatusDetails holds additional information for status.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
stacktrace
Package stacktrace provides support for gathering stack traces efficiently.
|
Package stacktrace provides support for gathering stack traces efficiently. |