Documentation
¶
Overview ¶
Package allure provides Allure provider as a plugin for testo.
Index ¶
- func Setup[T CommonT](t T, name string, f func(t T), options ...testoplugin.Option)
- func Step[T CommonT](t T, name string, f func(t T), options ...testoplugin.Option)
- func TearDown[T CommonT](t T, name string, f func(t T), options ...testoplugin.Option)
- func WithCategories(categories ...Category) testoplugin.Option
- func WithDeduplicateAttachments(deduplicate bool) testoplugin.Option
- func WithExcluded(excluded bool) testoplugin.Option
- func WithID(id string) testoplugin.Option
- func WithLabels(labels ...Label) testoplugin.Option
- func WithLinkTransformer(f LinkTransformerFunc) testoplugin.Option
- func WithLinks(links ...Link) testoplugin.Option
- func WithOutputDir(dir string) testoplugin.Option
- func WithOwner(owner string) testoplugin.Option
- func WithTags(tags ...string) testoplugin.Option
- type Assertions
- func (x Assertions) Condition(comp assert.Comparison, msgAndArgs ...interface{}) bool
- func (x Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) DirExists(path string, msgAndArgs ...interface{}) bool
- func (x Assertions) ElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) Empty(object interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) bool
- func (x Assertions) EqualExportedValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) Error(err error, msgAndArgs ...interface{}) bool
- func (x Assertions) ErrorAs(err error, target interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) ErrorContains(theError error, contains string, msgAndArgs ...interface{}) bool
- func (x Assertions) ErrorIs(err error, target error, msgAndArgs ...interface{}) bool
- func (x Assertions) Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, ...) bool
- func (x Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) False(value bool, msgAndArgs ...interface{}) bool
- func (x Assertions) FileExists(path string, msgAndArgs ...interface{}) bool
- func (x Assertions) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) GreaterOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, ...) bool
- func (x Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, ...) bool
- func (x Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, ...) bool
- func (x Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, ...) bool
- func (x Assertions) HTTPStatusCode(handler http.HandlerFunc, method string, url string, values url.Values, ...) bool
- func (x Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, ...) bool
- func (a Assertions) Hidden() Assertions
- func (x Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) InDelta(expected interface{}, actual interface{}, delta float64, ...) bool
- func (x Assertions) InDeltaMapValues(expected interface{}, actual interface{}, delta float64, ...) bool
- func (x Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, ...) bool
- func (x Assertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, ...) bool
- func (x Assertions) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, ...) bool
- func (x Assertions) IsDecreasing(object interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) IsIncreasing(object interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) IsNonDecreasing(object interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) IsNonIncreasing(object interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) bool
- func (x Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) bool
- func (x Assertions) Less(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) LessOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool
- func (a Assertions) Masked() Assertions
- func (x Assertions) Negative(e interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) Never(condition func() bool, waitFor time.Duration, tick time.Duration, ...) bool
- func (x Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) NoDirExists(path string, msgAndArgs ...interface{}) bool
- func (x Assertions) NoError(err error, msgAndArgs ...interface{}) bool
- func (x Assertions) NoFileExists(path string, msgAndArgs ...interface{}) bool
- func (x Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) NotElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) NotEqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) NotErrorAs(err error, target interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) NotErrorIs(err error, target error, msgAndArgs ...interface{}) bool
- func (x Assertions) NotImplements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
- func (x Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) NotSame(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
- func (x Assertions) PanicsWithError(errString string, f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
- func (x Assertions) PanicsWithValue(expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
- func (x Assertions) Positive(e interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) Same(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool
- func (x Assertions) True(value bool, msgAndArgs ...interface{}) bool
- func (x Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, ...) bool
- func (x Assertions) WithinRange(actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) bool
- func (x Assertions) YAMLEq(expected string, actual string, msgAndArgs ...interface{}) bool
- func (x Assertions) Zero(i interface{}, msgAndArgs ...interface{}) bool
- type Attachment
- type AttachmentBytes
- type AttachmentFile
- type Category
- type CommonT
- type Interface
- type Label
- type Link
- type LinkTransformerFunc
- type LinkType
- type MediaType
- type Parameter
- type ParameterMode
- type PluginAllure
- func (a *PluginAllure) Assert() Assertions
- func (a *PluginAllure) Attach(name string, at Attachment)
- func (a *PluginAllure) Description(desc string)
- func (a *PluginAllure) Descriptionf(format string, args ...any)
- func (a *PluginAllure) Epic(epic string)
- func (a *PluginAllure) Feature(feature string)
- func (a *PluginAllure) Flaky()
- func (a *PluginAllure) ID(id string)
- func (a *PluginAllure) Known()
- func (a *PluginAllure) Labels(labels ...Label)
- func (a *PluginAllure) Links(links ...Link)
- func (a *PluginAllure) Muted()
- func (a *PluginAllure) Owner(owner string)
- func (a *PluginAllure) Parameters(parameters ...Parameter)
- func (a *PluginAllure) Plugin(parent testoplugin.Plugin, options ...testoplugin.Option) testoplugin.Spec
- func (a *PluginAllure) Require() Requirements
- func (a *PluginAllure) Severity(severity Severity)
- func (a *PluginAllure) Status(status Status)
- func (a *PluginAllure) Story(story string)
- func (a *PluginAllure) Tags(tags ...string)
- func (a *PluginAllure) Title(title string)
- func (a *PluginAllure) Titlef(format string, args ...any)
- type Reflection
- type Requirements
- func (x Requirements) Condition(comp assert.Comparison, msgAndArgs ...interface{})
- func (x Requirements) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{})
- func (x Requirements) DirExists(path string, msgAndArgs ...interface{})
- func (x Requirements) ElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{})
- func (x Requirements) Empty(object interface{}, msgAndArgs ...interface{})
- func (x Requirements) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{})
- func (x Requirements) EqualError(theError error, errString string, msgAndArgs ...interface{})
- func (x Requirements) EqualExportedValues(expected interface{}, actual interface{}, msgAndArgs ...interface{})
- func (x Requirements) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{})
- func (x Requirements) Error(err error, msgAndArgs ...interface{})
- func (x Requirements) ErrorAs(err error, target interface{}, msgAndArgs ...interface{})
- func (x Requirements) ErrorContains(theError error, contains string, msgAndArgs ...interface{})
- func (x Requirements) ErrorIs(err error, target error, msgAndArgs ...interface{})
- func (x Requirements) Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, ...)
- func (x Requirements) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{})
- func (x Requirements) False(value bool, msgAndArgs ...interface{})
- func (x Requirements) FileExists(path string, msgAndArgs ...interface{})
- func (x Requirements) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
- func (x Requirements) GreaterOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
- func (x Requirements) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, ...)
- func (x Requirements) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, ...)
- func (x Requirements) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, ...)
- func (x Requirements) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, ...)
- func (x Requirements) HTTPStatusCode(handler http.HandlerFunc, method string, url string, values url.Values, ...)
- func (x Requirements) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, ...)
- func (r Requirements) Hidden() Requirements
- func (x Requirements) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{})
- func (x Requirements) InDelta(expected interface{}, actual interface{}, delta float64, ...)
- func (x Requirements) InDeltaMapValues(expected interface{}, actual interface{}, delta float64, ...)
- func (x Requirements) InDeltaSlice(expected interface{}, actual interface{}, delta float64, ...)
- func (x Requirements) InEpsilon(expected interface{}, actual interface{}, epsilon float64, ...)
- func (x Requirements) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, ...)
- func (x Requirements) IsDecreasing(object interface{}, msgAndArgs ...interface{})
- func (x Requirements) IsIncreasing(object interface{}, msgAndArgs ...interface{})
- func (x Requirements) IsNonDecreasing(object interface{}, msgAndArgs ...interface{})
- func (x Requirements) IsNonIncreasing(object interface{}, msgAndArgs ...interface{})
- func (x Requirements) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{})
- func (x Requirements) JSONEq(expected string, actual string, msgAndArgs ...interface{})
- func (x Requirements) Len(object interface{}, length int, msgAndArgs ...interface{})
- func (x Requirements) Less(e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
- func (x Requirements) LessOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
- func (r Requirements) Masked() Requirements
- func (x Requirements) Negative(e interface{}, msgAndArgs ...interface{})
- func (x Requirements) Never(condition func() bool, waitFor time.Duration, tick time.Duration, ...)
- func (x Requirements) Nil(object interface{}, msgAndArgs ...interface{})
- func (x Requirements) NoDirExists(path string, msgAndArgs ...interface{})
- func (x Requirements) NoError(err error, msgAndArgs ...interface{})
- func (x Requirements) NoFileExists(path string, msgAndArgs ...interface{})
- func (x Requirements) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{})
- func (x Requirements) NotElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{})
- func (x Requirements) NotEmpty(object interface{}, msgAndArgs ...interface{})
- func (x Requirements) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{})
- func (x Requirements) NotEqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{})
- func (x Requirements) NotErrorAs(err error, target interface{}, msgAndArgs ...interface{})
- func (x Requirements) NotErrorIs(err error, target error, msgAndArgs ...interface{})
- func (x Requirements) NotImplements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{})
- func (x Requirements) NotNil(object interface{}, msgAndArgs ...interface{})
- func (x Requirements) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{})
- func (x Requirements) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{})
- func (x Requirements) NotSame(expected interface{}, actual interface{}, msgAndArgs ...interface{})
- func (x Requirements) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{})
- func (x Requirements) NotZero(i interface{}, msgAndArgs ...interface{})
- func (x Requirements) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{})
- func (x Requirements) PanicsWithError(errString string, f assert.PanicTestFunc, msgAndArgs ...interface{})
- func (x Requirements) PanicsWithValue(expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{})
- func (x Requirements) Positive(e interface{}, msgAndArgs ...interface{})
- func (x Requirements) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{})
- func (x Requirements) Same(expected interface{}, actual interface{}, msgAndArgs ...interface{})
- func (x Requirements) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{})
- func (x Requirements) True(value bool, msgAndArgs ...interface{})
- func (x Requirements) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, ...)
- func (x Requirements) WithinRange(actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{})
- func (x Requirements) YAMLEq(expected string, actual string, msgAndArgs ...interface{})
- func (x Requirements) Zero(i interface{}, msgAndArgs ...interface{})
- type Severity
- type Status
- type StatusDetails
- type UUID
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Setup ¶
func Setup[T CommonT]( t T, name string, f func(t T), options ...testoplugin.Option, )
Setup runs a Step marked as Setup in Allure report.
See also TearDown.
func Step ¶
func Step[T CommonT]( t T, name string, f func(t T), options ...testoplugin.Option, )
Step wraps testo.Run with some differences:
- if the step fails (before call to t.Parallel) with fatal error, outer test execution will stop.
- context returned by the t.Context will cancel when parent context does.
NOTE: testo.Run is also treated as Allure step in the report.
WARN: Running this function during t.Cleanup panics.
func TearDown ¶
func TearDown[T CommonT]( t T, name string, f func(t T), options ...testoplugin.Option, )
TearDown runs a Step marked as TearDown in Allure report.
See also Setup.
func WithCategories ¶
func WithCategories(categories ...Category) testoplugin.Option
WithCategories adds custom categories to the report. This option should be passed to the top-level testo.RunSuite call.
func WithDeduplicateAttachments ¶
func WithDeduplicateAttachments(deduplicate bool) testoplugin.Option
WithDeduplicateAttachments enables deduplication of attachment files.
If enabled, plugin will keep track of all written attachments, so that each attachment is written at most once and multiple tests will reference the same attachment.
func WithExcluded ¶
func WithExcluded(excluded bool) testoplugin.Option
WithExcluded will mark this test or step as excluded from the report.
func WithID ¶
func WithID(id string) testoplugin.Option
WithID will set the given id as AllureID for this test.
If Allure TestOps discovers ID in a test result, it ignores all the information related to testCaseId and links the test result to a particular test case.
See Cooking the AllureID for more information.
func WithLabels ¶
func WithLabels(labels ...Label) testoplugin.Option
WithLabels adds given labels to this test and all of its subtests.
func WithLinkTransformer ¶
func WithLinkTransformer(f LinkTransformerFunc) testoplugin.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 WithLinks ¶
func WithLinks(links ...Link) testoplugin.Option
WithLinks sets passed links for this test and all of its subtests.
func WithOutputDir ¶
func WithOutputDir(dir string) testoplugin.Option
WithOutputDir sets output directory for test results.
By default, it is "allure-results" in the current working directory.
func WithOwner ¶
func WithOwner(owner string) testoplugin.Option
WithOwner sets an owner for this test and all of its subtests.
func WithTags ¶
func WithTags(tags ...string) testoplugin.Option
WithTags adds given tags to this test and all of its subtests.
Types ¶
type Assertions ¶
type Assertions 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) Condition ¶
func (x Assertions) Condition(comp assert.Comparison, msgAndArgs ...interface{}) bool
Condition uses a Comparison to assert a complex condition.
func (Assertions) Contains ¶
func (x Assertions) 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) DirExists ¶
func (x Assertions) 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) ElementsMatch ¶
func (x Assertions) 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) Empty ¶
func (x Assertions) 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) Equal ¶
func (x Assertions) 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) EqualError ¶
func (x Assertions) 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) EqualExportedValues ¶
func (x Assertions) 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) EqualValues ¶
func (x Assertions) 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) Error ¶
func (x Assertions) 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) ErrorAs ¶
func (x Assertions) 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) ErrorContains ¶
func (x Assertions) 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) ErrorIs ¶
func (x Assertions) 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) Eventually ¶
func (x Assertions) 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) Exactly ¶
func (x Assertions) 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) False ¶
func (x Assertions) False(value bool, msgAndArgs ...interface{}) bool
False asserts that the specified value is false.
assert.False(t, myBool)
func (Assertions) FileExists ¶
func (x Assertions) 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) Greater ¶
func (x Assertions) 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) GreaterOrEqual ¶
func (x Assertions) 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) HTTPBodyContains ¶
func (x Assertions) 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) HTTPBodyNotContains ¶
func (x Assertions) 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) HTTPError ¶
func (x Assertions) 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) HTTPRedirect ¶
func (x Assertions) 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) HTTPStatusCode ¶
func (x Assertions) 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) HTTPSuccess ¶
func (x Assertions) 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) Hidden ¶
func (a Assertions) Hidden() Assertions
Hidden returns a new assertions instance which will hide its parameters.
func (Assertions) Implements ¶
func (x Assertions) 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) InDelta ¶
func (x Assertions) 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) InDeltaMapValues ¶
func (x Assertions) 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) InDeltaSlice ¶
func (x Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool
InDeltaSlice is the same as InDelta, except it compares two slices.
func (Assertions) InEpsilon ¶
func (x Assertions) 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) InEpsilonSlice ¶
func (x Assertions) 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) IsDecreasing ¶
func (x Assertions) 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) IsIncreasing ¶
func (x Assertions) 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) IsNonDecreasing ¶
func (x Assertions) 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) IsNonIncreasing ¶
func (x Assertions) 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) IsType ¶
func (x Assertions) 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) JSONEq ¶
func (x Assertions) 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) Len ¶
func (x Assertions) 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) Less ¶
func (x Assertions) 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) LessOrEqual ¶
func (x Assertions) 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) Masked ¶
func (a Assertions) Masked() Assertions
Masked returns a new assertions instance which will mask its parameters.
func (Assertions) Negative ¶
func (x Assertions) 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) Never ¶
func (x Assertions) 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) Nil ¶
func (x Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool
Nil asserts that the specified object is nil.
assert.Nil(t, err)
func (Assertions) NoDirExists ¶
func (x Assertions) 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) NoError ¶
func (x Assertions) 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) NoFileExists ¶
func (x Assertions) 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) NotContains ¶
func (x Assertions) 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) NotElementsMatch ¶
func (x Assertions) 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) NotEmpty ¶
func (x Assertions) 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) NotEqual ¶
func (x Assertions) 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) NotEqualValues ¶
func (x Assertions) 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) NotErrorAs ¶
func (x Assertions) 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) NotErrorIs ¶
func (x Assertions) 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) NotImplements ¶
func (x Assertions) 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) NotNil ¶
func (x Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool
NotNil asserts that the specified object is not nil.
assert.NotNil(t, err)
func (Assertions) NotPanics ¶
func (x Assertions) 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) NotRegexp ¶
func (x Assertions) 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) NotSame ¶
func (x Assertions) 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) NotSubset ¶
func (x Assertions) 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) NotZero ¶
func (x Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) bool
NotZero asserts that i is not the zero value for its type.
func (Assertions) Panics ¶
func (x Assertions) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
Panics asserts that the code inside the specified PanicTestFunc panics.
assert.Panics(t, func(){ GoCrazy() })
func (Assertions) PanicsWithError ¶
func (x Assertions) 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) PanicsWithValue ¶
func (x Assertions) 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) Positive ¶
func (x Assertions) 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) Regexp ¶
func (x Assertions) 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) Same ¶
func (x Assertions) 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) Subset ¶
func (x Assertions) 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) True ¶
func (x Assertions) True(value bool, msgAndArgs ...interface{}) bool
True asserts that the specified value is true.
assert.True(t, myBool)
func (Assertions) WithinDuration ¶
func (x Assertions) 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) WithinRange ¶
func (x Assertions) 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) YAMLEq ¶
func (x Assertions) YAMLEq(expected string, actual string, msgAndArgs ...interface{}) bool
YAMLEq asserts that two YAML strings are equivalent.
func (Assertions) Zero ¶
func (x Assertions) 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)
// Type returns the media type of the content.
Type() MediaType
// SizeHint returns attachment size as in bytes count.
SizeHint() (size int64, ok bool)
}
Attachment to add into report.
See Allure attachments for more information.
type AttachmentBytes ¶
AttachmentBytes is an attachment which stores its contents in-memory. Consider using AttachmentFile for large, static files.
func Bytes ¶
func Bytes[BytesLike ~string | ~[]byte](data BytesLike) AttachmentBytes
Bytes creates a new bytes attachment from the given bytes or string.
See AttachmentBytes.As to specify media type for preview in Allure report. If not specified, media type will be guessed based on the data contents with fallback to "application/octet-stream" when writing attachment to the report.
Media type guesser is backed by gabriel-vasile/mimetype.
allure.Bytes([]byte{...}).As(allure.DocumentJSON)
allure.Bytes(`{"name":"value"}`)
allure.Bytes("Hello, world!")
Example ¶
a := Bytes([]byte(`{"name": "value"}`)).As(DocumentJSON)
fmt.Println(a.Type())
Output: application/json
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) SizeHint ¶
func (b AttachmentBytes) SizeHint() (int64, bool)
SizeHint returns bytes data len.
func (AttachmentBytes) Type ¶
func (b AttachmentBytes) Type() MediaType
Type returns the media type of the content.
type AttachmentFile ¶
AttachmentFile is an attachment stored in the file located at path.
func File ¶
func File(path string) AttachmentFile
File creates a new attachment from the given file path.
Media type will be guessed based on the file extension. If file extension is missing or unknown, media type will be guessed later based on the file contents when writing attachment to the report.
Use [AttachmentFile.Bytes] method to convert it to AttachmentBytes immediately.
allure.File("/home/user/file.txt")
allure.File("/home/user/file.json").As(allure.DocumentYAML)
allure.File("/home/user/file")
func (AttachmentFile) As ¶
func (f AttachmentFile) As(mediaType MediaType) AttachmentFile
As returns new attachment with the given media type.
func (AttachmentFile) Open ¶
func (f AttachmentFile) Open() (io.ReadCloser, error)
Open attachment for reading.
func (AttachmentFile) SizeHint ¶
func (f AttachmentFile) SizeHint() (int64, bool)
SizeHint returns size of the file pointer by path.
func (AttachmentFile) Type ¶
func (f AttachmentFile) Type() MediaType
Type returns the media type of the content.
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,omitempty"`
// TraceRegex is the regular expression that
// the test result's trace should match.
TraceRegex string `json:"traceRegex,omitempty"`
// MatchedStatuses are the statuses that
// the test result should be one of.
MatchedStatuses []Status `json:"matchedStatuses,omitempty"`
}
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 {
// Require returns a new [Requirements] instance.
Require() Requirements
// Assert returns a new [Assertions] instance.
Assert() Assertions
// Title sets a human-readable title of the test.
//
// If not provided, function or subtest name is used instead.
//
// t.Title("My Test")
Title(title string)
// Titlef is the same as [PluginAllure.Title] but
// uses [fmt.Sprintf] to set a title.
//
// t.Titlef("Request to %s", url)
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 apply some basic formatting in it.
// HTML tags are not allowed in such a text and will
// be removed when building the report.
//
// t.Description("Test description with **markdown** _support_!")
Description(desc string)
// Descriptionf is the same as [PluginAllure.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 [PluginAllure.Tags] or [PluginAllure.Severity]
// instead of using labels directly.
//
// t.Labels(allure.NewLabel("name", "value"), allure.NewLabel("otherLabel", "42"))
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].
//
// t.Tags("heavy", "other tag")
//
// [filtering]: https://allurereport.org/docs/sorting-and-filtering/#filter-tests-by-tags
Tags(tags ...string)
// ID specifies unique identifier of this test in Allure TestOps' database.
//
// If Allure TestOps discovers ID in a test result, it ignores all
// the information related to testCaseId and links the test result to a particular test case.
//
// See [Cooking the AllureID] for more information.
//
// [Cooking the AllureID]: https://help.qameta.io/support/solutions/articles/101000480600-cooking-the-allureid
ID(id string)
// Status overwrites the status with which the test or step finished.
//
// Unless this method was called with known status,
// allure plugin will automatically derive a status with the following rules:
//
// - [StatusBroken] if the test panicked.
// - [StatusFailed] if the test has failed.
// - [StatusSkipped] if the test was skipped.
// - [StatusPassed] otherwise.
Status(status Status)
// Parameters adds parameters to show for this report in the result.
//
// Allure plugin automatically sets parameters for parametrized tests.
// This behavior can be configured with [WithAutoParameters] option.
//
// t.Parameters(allure.NewParameter("login", "john doe"), allure.NewParameter("age", 42))
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.
//
// t.Owner("John Doe")
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.
//
// t.Severity(allure.SeverityCritical)
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 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 [Bytes] and [File] to create an attachment.
//
// t.Attach("login page", allure.Bytes([]byte(...)))
// t.Attach("server response", allure.Bytes(`{"key": "value"}`))
Attach(name string, at Attachment)
// contains filtered or unexported methods
}
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 of the parameter.
Name string
// Value of the parameter.
Value any
// Exclude parameter when comparing
// the current result with the previous one in the history.
Exclude bool
// Mode of the parameter.
Mode ParameterMode
}
Parameter to show in the report.
Allure plugin automatically sets parameters for parametrized tests.
func NewParameter ¶
NewParameter constructs a new Parameter.
t.Parameters(allure.NewParameter("arg", 42))
func (Parameter) Excluded ¶
Excluded returns a new parameter marked as excluded.
Excluded parameters are ignored when comparing the current result with the previous one in the history.
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 PluginAllure ¶
PluginAllure defines allure plugin.
func (*PluginAllure) Assert ¶
func (a *PluginAllure) Assert() Assertions
Assert returns a new Assertions instance.
func (*PluginAllure) Attach ¶
func (a *PluginAllure) Attach(name string, at Attachment)
Attach an attachment.
See Bytes and File to create an attachment.
t.Attach("login page", allure.Bytes([]byte(...)))
t.Attach("server response", allure.Bytes(`{"key": "value"}`))
func (*PluginAllure) Description ¶
func (a *PluginAllure) Description(desc string)
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 apply some basic formatting in it. HTML tags are not allowed in such a text and will be removed when building the report.
t.Description("Test description with **markdown** _support_!")
func (*PluginAllure) Descriptionf ¶
func (a *PluginAllure) Descriptionf(format string, args ...any)
Descriptionf is the same as PluginAllure.Description but uses fmt.Sprintf to set a description.
func (*PluginAllure) Feature ¶
func (a *PluginAllure) Feature(feature string)
Feature linked to this test.
func (*PluginAllure) Flaky ¶
func (a *PluginAllure) Flaky()
Flaky indicates that this test or step is known to be unstable and may not succeed every time.
func (*PluginAllure) ID ¶
func (a *PluginAllure) ID(id string)
ID specifies unique identifier of this test in Allure TestOps' database.
If Allure TestOps discovers ID in a test result, it ignores all the information related to testCaseId and links the test result to a particular test case.
See Cooking the AllureID for more information.
func (*PluginAllure) Known ¶
func (a *PluginAllure) Known()
Known indicates that the test fails because of a known bug.
func (*PluginAllure) Labels ¶
func (a *PluginAllure) Labels(labels ...Label)
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 PluginAllure.Tags or PluginAllure.Severity instead of using labels directly.
t.Labels(allure.NewLabel("name", "value"), allure.NewLabel("otherLabel", "42"))
func (*PluginAllure) Links ¶
func (a *PluginAllure) Links(links ...Link)
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 (*PluginAllure) Muted ¶
func (a *PluginAllure) Muted()
Muted indicates that the result must not affect the statistics.
func (*PluginAllure) Owner ¶
func (a *PluginAllure) Owner(owner string)
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.
t.Owner("John Doe")
func (*PluginAllure) Parameters ¶
func (a *PluginAllure) Parameters(parameters ...Parameter)
Parameters adds parameters to show for this report in the result.
Allure plugin automatically sets parameters for parametrized tests. This behavior can be configured with [WithAutoParameters] option.
t.Parameters(allure.NewParameter("login", "john doe"), allure.NewParameter("age", 42))
func (*PluginAllure) Plugin ¶
func (a *PluginAllure) Plugin( parent testoplugin.Plugin, options ...testoplugin.Option, ) testoplugin.Spec
Plugin implements testoplugin.Plugin.
func (*PluginAllure) Require ¶
func (a *PluginAllure) Require() Requirements
Require returns a new Requirements instance.
func (*PluginAllure) Severity ¶
func (a *PluginAllure) Severity(severity 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.
t.Severity(allure.SeverityCritical)
func (*PluginAllure) Status ¶
func (a *PluginAllure) Status(status Status)
Status overwrites the status with which the test or step finished.
Unless this method was called with known status, allure plugin will automatically derive a status with the following rules:
- StatusBroken if the test panicked.
- StatusFailed if the test has failed.
- StatusSkipped if the test was skipped.
- StatusPassed otherwise.
func (*PluginAllure) Tags ¶
func (a *PluginAllure) Tags(tags ...string)
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.
t.Tags("heavy", "other tag")
func (*PluginAllure) Title ¶
func (a *PluginAllure) Title(title string)
Title sets a human-readable title of the test.
If not provided, function or subtest name is used instead.
t.Title("My Test")
func (*PluginAllure) Titlef ¶
func (a *PluginAllure) Titlef(format string, args ...any)
Titlef is the same as PluginAllure.Title but uses fmt.Sprintf to set a title.
t.Titlef("Request to %s", url)
type Reflection ¶
type Reflection struct {
UUID UUID
TestCaseID string
HistoryID string
FullName string
Description string
Parameters []Parameter
Labels []Label
Links []Link
Severity Severity
Status Status
StatusDetails StatusDetails
Categories []Category
Title string
}
Reflection holds information about current allure state.
func Reflect ¶
func Reflect(t Interface) Reflection
Reflect returns Reflection for the underlying allure state.
type Requirements ¶
type Requirements struct {
// contains filtered or unexported fields
}
Requirements implements the same assertions as Assertions but stops test execution when assertion fails.
func (Requirements) Condition ¶
func (x Requirements) Condition(comp assert.Comparison, msgAndArgs ...interface{})
Condition uses a Comparison to assert a complex condition.
func (Requirements) Contains ¶
func (x Requirements) 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) DirExists ¶
func (x Requirements) 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) ElementsMatch ¶
func (x Requirements) 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) Empty ¶
func (x Requirements) 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) Equal ¶
func (x Requirements) 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) EqualError ¶
func (x Requirements) 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) EqualExportedValues ¶
func (x Requirements) 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) EqualValues ¶
func (x Requirements) 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) Error ¶
func (x Requirements) 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) ErrorAs ¶
func (x Requirements) 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) ErrorContains ¶
func (x Requirements) 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) ErrorIs ¶
func (x Requirements) 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) Eventually ¶
func (x Requirements) 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) Exactly ¶
func (x Requirements) 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) False ¶
func (x Requirements) False(value bool, msgAndArgs ...interface{})
False asserts that the specified value is false.
assert.False(t, myBool)
func (Requirements) FileExists ¶
func (x Requirements) 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) Greater ¶
func (x Requirements) 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) GreaterOrEqual ¶
func (x Requirements) 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) HTTPBodyContains ¶
func (x Requirements) 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) HTTPBodyNotContains ¶
func (x Requirements) 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) HTTPError ¶
func (x Requirements) 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) HTTPRedirect ¶
func (x Requirements) 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) HTTPStatusCode ¶
func (x Requirements) 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) HTTPSuccess ¶
func (x Requirements) 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) Hidden ¶
func (r Requirements) Hidden() Requirements
Hidden returns a new requirements instance which will hide its parameters.
func (Requirements) Implements ¶
func (x Requirements) 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) InDelta ¶
func (x Requirements) 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) InDeltaMapValues ¶
func (x Requirements) 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) InDeltaSlice ¶
func (x Requirements) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{})
InDeltaSlice is the same as InDelta, except it compares two slices.
func (Requirements) InEpsilon ¶
func (x Requirements) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{})
InEpsilon asserts that expected and actual have a relative error less than epsilon
func (Requirements) InEpsilonSlice ¶
func (x Requirements) 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) IsDecreasing ¶
func (x Requirements) 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) IsIncreasing ¶
func (x Requirements) 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) IsNonDecreasing ¶
func (x Requirements) 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) IsNonIncreasing ¶
func (x Requirements) 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) IsType ¶
func (x Requirements) 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) JSONEq ¶
func (x Requirements) 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) Len ¶
func (x Requirements) 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) Less ¶
func (x Requirements) 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) LessOrEqual ¶
func (x Requirements) 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) Masked ¶
func (r Requirements) Masked() Requirements
Masked returns a new requirements instance which will mask its parameters.
func (Requirements) Negative ¶
func (x Requirements) Negative(e interface{}, msgAndArgs ...interface{})
Negative asserts that the specified element is negative
assert.Negative(t, -1) assert.Negative(t, -1.23)
func (Requirements) Never ¶
func (x Requirements) 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) Nil ¶
func (x Requirements) Nil(object interface{}, msgAndArgs ...interface{})
Nil asserts that the specified object is nil.
assert.Nil(t, err)
func (Requirements) NoDirExists ¶
func (x Requirements) 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) NoError ¶
func (x Requirements) 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) NoFileExists ¶
func (x Requirements) 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) NotContains ¶
func (x Requirements) 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) NotElementsMatch ¶
func (x Requirements) 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) NotEmpty ¶
func (x Requirements) 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) NotEqual ¶
func (x Requirements) 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) NotEqualValues ¶
func (x Requirements) 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) NotErrorAs ¶
func (x Requirements) 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) NotErrorIs ¶
func (x Requirements) 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) NotImplements ¶
func (x Requirements) 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) NotNil ¶
func (x Requirements) NotNil(object interface{}, msgAndArgs ...interface{})
NotNil asserts that the specified object is not nil.
assert.NotNil(t, err)
func (Requirements) NotPanics ¶
func (x Requirements) 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) NotRegexp ¶
func (x Requirements) 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) NotSame ¶
func (x Requirements) 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) NotSubset ¶
func (x Requirements) 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) NotZero ¶
func (x Requirements) NotZero(i interface{}, msgAndArgs ...interface{})
NotZero asserts that i is not the zero value for its type.
func (Requirements) Panics ¶
func (x Requirements) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{})
Panics asserts that the code inside the specified PanicTestFunc panics.
assert.Panics(t, func(){ GoCrazy() })
func (Requirements) PanicsWithError ¶
func (x Requirements) 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) PanicsWithValue ¶
func (x Requirements) 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) Positive ¶
func (x Requirements) Positive(e interface{}, msgAndArgs ...interface{})
Positive asserts that the specified element is positive
assert.Positive(t, 1) assert.Positive(t, 1.23)
func (Requirements) Regexp ¶
func (x Requirements) 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) Same ¶
func (x Requirements) 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) Subset ¶
func (x Requirements) 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) True ¶
func (x Requirements) True(value bool, msgAndArgs ...interface{})
True asserts that the specified value is true.
assert.True(t, myBool)
func (Requirements) WithinDuration ¶
func (x Requirements) 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) WithinRange ¶
func (x Requirements) 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) YAMLEq ¶
func (x Requirements) YAMLEq(expected string, actual string, msgAndArgs ...interface{})
YAMLEq asserts that two YAML strings are equivalent.
func (Requirements) Zero ¶
func (x Requirements) 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 ( // SeverityTrivial is the least severe level. // // Usually related to minor, non-critical issues that have // little to no impact on the overall user experience. SeverityTrivial Severity = -2 // SeverityMinor indicates minor issues, such as cosmetic problems // or small functional discrepancies. SeverityMinor Severity = -1 // SeverityNormal is the default severity. // // Tests at this level indicate regular or expected issues // and do not pose a major threat to the application's stability. SeverityNormal Severity = 0 // SeverityCritical is for tests that identify serious problems // with the system's functionality, though not necessarily a complete blocker. SeverityCritical Severity = 1 // SeverityBlocker is the most severe level. // // Tests flagged as "blocker" are critical issues that // prevent core functionality and require immediate attention on failure. SeverityBlocker Severity = 2 )
Possible severity values.
func (Severity) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
type Status ¶
type Status int
Status is the test status.
See Test statuses for more information.
const ( // StatusPassed is a passed test (green) is a test that finished successfully. // This usually means that the tested scenario works as expected. // // https://allurereport.org/docs/test-statuses/#passed StatusPassed Status = iota + 1 // StatusFailed is a failed test (red) is a test that encountered // an unexpected behavior in the system under test. // This means that the test itself seems to be valid (not [StatusBroken]), // but its execution ended with a false assertion. // // Note that a failure of a step does not necessarily cause a failure of the test as a whole. // // https://allurereport.org/docs/test-statuses/#failed StatusFailed // StatusSkipped is a skipped test (gray) is a test that // was included in the test plan but then not executed. // // https://allurereport.org/docs/test-statuses/#skipped StatusSkipped // StatusBroken is a broken test (yellow) is a test that // failed because of a test defect. Unlike Failed, this // status means that the test was unable to check the product's behavior // as it intended to, therefore, the failure may or may not indicate an actual product defect. // // https://allurereport.org/docs/test-statuses/#broken StatusBroken )
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. |