Documentation ¶
Index ¶
- func WithBody(body []byte) func(o *requestOptions)
- func WithFileForm(fileForms map[string]*File) func(o *requestOptions)
- func WithFileFormKV(name string, file *File) func(o *requestOptions)
- func WithForm(forms map[string][]byte) func(o *requestOptions)
- func WithFormKV(name string, body []byte) func(o *requestOptions)
- func WithHeaders(headers map[string][]string) func(o *requestOptions)
- func WithHeadersKV(name string, value string) func(o *requestOptions)
- func WithMarshalBody(body interface{}) func(o *requestOptions)
- func WithMethod(method string) func(o *requestOptions)
- func WithQuery(queries map[string][]string) func(o *requestOptions)
- func WithQueryKV(name string, value string) func(o *requestOptions)
- func WithURI(uri string) func(o *requestOptions)
- func WithURL(url *url.URL) func(o *requestOptions)
- type After
- type AfterExecute
- type AfterExecuteT
- type AfterTest
- type AfterTestExecute
- type AllureBuilder
- type AllureInfoBuilder
- type AllureLabelsBuilder
- type AllureLinksBuilder
- type AllureStep
- type AssertBody
- type AssertBodyT
- type AssertHeaders
- type AssertHeadersT
- type AssertResponse
- type AssertResponseT
- type BeforeExecute
- type BeforeExecuteT
- type BeforeTest
- type ControlTest
- type CreateBuilder
- type Expect
- type ExpectHTTPBuilder
- type ExpectJSONSchema
- type File
- type HTTPTestMaker
- type JSONMarshaler
- type Middleware
- type MiddlewareRequest
- type MiddlewareTable
- type NextTestBuilder
- type Option
- func WithCustomHTTPRoundTripper(r http.RoundTripper) Option
- func WithCustomHTTPTimeout(t time.Duration) Option
- func WithHTTPClient(client *http.Client) Option
- func WithJSONMarshaler(m JSONMarshaler) Option
- func WithMiddlewareAfter(after ...AfterExecute) Option
- func WithMiddlewareAfterT(after ...AfterExecuteT) Option
- func WithMiddlewareBefore(before ...BeforeExecute) Option
- func WithMiddlewareBeforeT(beforeT ...BeforeExecuteT) Option
- type Request
- type RequestBuilder
- type RequestHTTPBuilder
- type RequestParams
- type RequestRepeatPolitic
- type ResultState
- type ResultsHTTPBuilder
- type T
- type TableTest
- type Test
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithBody ¶
func WithBody(body []byte) func(o *requestOptions)
WithBody is a function for set body in request
func WithFileForm ¶ added in v0.1.10
WithFileForm is a function for set file form in request
func WithFileFormKV ¶ added in v0.1.10
WithFileFormKV is a function for set file form in request
func WithFormKV ¶ added in v0.1.10
WithFormKV is a function for set body in form request
func WithHeaders ¶
WithHeaders is a function for set or merge headers in request
func WithHeadersKV ¶ added in v0.1.10
WithHeadersKV is a function for set headers in request
func WithMarshalBody ¶
func WithMarshalBody(body interface{}) func(o *requestOptions)
WithMarshalBody is a function for marshal body and set body in request
func WithMethod ¶
func WithMethod(method string) func(o *requestOptions)
WithMethod is a function for set method (GET, POST ...) in request
func WithQuery ¶ added in v0.1.11
WithQuery is a function for set or merge query parameters in request
func WithQueryKV ¶ added in v0.1.11
WithQueryKV is a function for set query in request
Types ¶
type After ¶ added in v0.1.9
type After interface { // After is function for processing response after test execution After(...AfterExecute) ExpectHTTPBuilder // AfterT is function for processing response after test execution AfterT(...AfterExecuteT) ExpectHTTPBuilder }
After are functions for processing response after test execution Same functions: AfterText AfterTestExecute
type AfterExecute ¶
AfterExecute is a function for processing response after test execution
type AfterExecuteT ¶
AfterExecuteT is a function for processing response after test execution
type AfterTest ¶ added in v0.1.6
type AfterTest interface { // AfterExecute is function for processing response after test execution AfterExecute(...AfterExecute) MiddlewareRequest // AfterExecuteT is function for processing response after test execution AfterExecuteT(...AfterExecuteT) MiddlewareRequest }
AfterTest are functions for processing response after test execution Same functions: After AfterTestExecute
type AfterTestExecute ¶ added in v0.1.9
type AfterTestExecute interface { // AfterTestExecute is function for processing response after test execution AfterTestExecute(...AfterExecute) NextTestBuilder // AfterTestExecuteT is function for processing response after test execution AfterTestExecuteT(...AfterExecuteT) NextTestBuilder }
AfterTestExecute are functions for processing response after test execution Same functions: After AfterText
type AllureBuilder ¶
type AllureBuilder interface { AllureInfoBuilder AllureLabelsBuilder AllureLinksBuilder CreateBuilder // Parallel signals that this Test is to be run in parallel with (and only with) other parallel tests. // This function is not thread save. If you use multiply parallel with one T Test will panic. Parallel() AllureBuilder }
AllureBuilder is a scope of methods for create allure information (Title, Tags, etc.)
func NewTestBuilder ¶
func NewTestBuilder() AllureBuilder
NewTestBuilder is function for create base test builder, For create custom test builder use NewHTTPTestMaker()
type AllureInfoBuilder ¶
type AllureInfoBuilder interface { // Title is a function for set title in allure information Title(title string) AllureBuilder Titlef(format string, args ...interface{}) AllureBuilder // Description is a function for set description in allure information Description(description string) AllureBuilder Descriptionf(format string, args ...interface{}) AllureBuilder Stage(stage string) AllureBuilder Stagef(format string, args ...interface{}) AllureBuilder }
AllureInfoBuilder is a scope of methods for create allure information (Title, Tags, etc.)
type AllureLabelsBuilder ¶
type AllureLabelsBuilder interface { Feature(feature string) AllureBuilder Epic(epic string) AllureBuilder AllureID(value string) AllureBuilder Tags(tags ...string) AllureBuilder ID(value string) AllureBuilder AddSuiteLabel(value string) AllureBuilder AddSubSuite(value string) AllureBuilder AddParentSuite(value string) AllureBuilder Story(value string) AllureBuilder Tag(value string) AllureBuilder Severity(value allure.SeverityType) AllureBuilder Owner(value string) AllureBuilder Lead(value string) AllureBuilder Label(label *allure.Label) AllureBuilder Labels(labels ...*allure.Label) AllureBuilder Layer(value string) AllureBuilder Stagef(format string, args ...interface{}) AllureBuilder Stage(stage string) AllureBuilder }
AllureLabelsBuilder is a scope of methods to set allure labels
type AllureLinksBuilder ¶
type AllureLinksBuilder interface { SetIssue(issue string) AllureBuilder SetTestCase(testCase string) AllureBuilder Link(link *allure.Link) AllureBuilder TmsLink(tmsLink string) AllureBuilder TmsLinks(tmsLinks ...string) AllureBuilder }
AllureLinksBuilder is a scope of methods to set allure links
type AllureStep ¶ added in v0.1.6
type AllureStep struct {
Name string
}
AllureStep is struct with test name
type AssertBody ¶
AssertBody is type for create custom assertions for body Example asserts: - json.LengthGreaterThan - json.LengthGreaterOrEqualThan - json.LengthLessThan - json.LengthLessOrEqualThan - json.Present - json.NotEmpty - json.NotPresent
type AssertBodyT ¶
AssertBodyT is type for create custom assertions for body with TB Check example in AssertBody TB is testing.T and it can be used for require ore assert from testify or another packages
type AssertHeaders ¶
AssertHeaders is type for create custom assertions for headers Example asserts: - headers.Present - headers.NotPresent
type AssertHeadersT ¶
AssertHeadersT is type for create custom assertions for headers with TB Check example in AssertHeaders TB is testing.T and it can be used for require ore assert from testify or another packages
type AssertResponse ¶
AssertResponse is type for create custom assertions for response
type AssertResponseT ¶
AssertResponseT is type for create custom assertions for response with TB Check example in AssertResponse TB is testing.T and it can be used for require ore assert from testify or another packages
type BeforeExecute ¶
BeforeExecute is a function for processing request before test execution
type BeforeExecuteT ¶
BeforeExecuteT is a function for processing request before test execution
type BeforeTest ¶ added in v0.1.6
type BeforeTest interface { // BeforeExecute is function for processing request before test execution BeforeExecute(...BeforeExecute) MiddlewareRequest // BeforeExecuteT is function for processing request before test execution BeforeExecuteT(...BeforeExecuteT) MiddlewareRequest }
BeforeTest are functions for processing request before test execution Same functions: Before
type ControlTest ¶ added in v0.1.6
type ControlTest interface { NextTest() NextTestBuilder // ExecuteTest is a function for execute Test ExecuteTest(ctx context.Context, t tProvider) []ResultsHTTPBuilder }
ControlTest is function for manipulating tests
type CreateBuilder ¶ added in v0.1.6
type CreateBuilder interface { // Create is a function for save main information about allure and start write tests Create() MiddlewareRequest // CreateStep is a function for create step inside suite for Test CreateStep(string) MiddlewareRequest // CreateTableTest is function for create table Test CreateTableTest() MiddlewareTable }
CreateBuilder is functions for create Test or table tests
type Expect ¶ added in v0.1.6
type Expect struct { ExecuteTime time.Duration Code int JSONSchema *ExpectJSONSchema AssertBody []AssertBody AssertHeaders []AssertHeaders AssertResponse []AssertResponse AssertBodyT []AssertBodyT AssertHeadersT []AssertHeadersT AssertResponseT []AssertResponseT }
Expect is structs with validate politics for response
type ExpectHTTPBuilder ¶
type ExpectHTTPBuilder interface { // ExpectExecuteTimeout is function for validate time of execution // Default value - 10 seconds ExpectExecuteTimeout(t time.Duration) ExpectHTTPBuilder // ExpectStatus is function for validate response status code ExpectStatus(code int) ExpectHTTPBuilder // ExpectJSONSchemaString is function for validate response by json schema from string ExpectJSONSchemaString(schema string) ExpectHTTPBuilder // ExpectJSONSchemaByte is function for validate response by json schema from byte ExpectJSONSchemaByte(schema []byte) ExpectHTTPBuilder // ExpectJSONSchemaFile is function for validate response by json schema from file // For get file from network use: // "http://www.some_host.com/schema.json" // For get local file use: // "file://./project/me/schema.json" ExpectJSONSchemaFile(path string) ExpectHTTPBuilder // AssertBody is function for validate response body. // Available asserts from asserts/json/json.go: // Contains is a function to assert that a jsonpath expression extracts a value in an array // Equal is a function to assert that a jsonpath expression matches the given value // NotEqual is a function to check jsonpath expression value is not equal to given value // Length is a function to asserts that jsonpath expression value is the expected length // GreaterThan is a function to asserts that jsonpath expression value is greater than the given length // LessThan is a function to asserts that jsonpath expression value is less than the given length // Present is a function to asserts that jsonpath expression value is present // NotPresent is a function to asserts that jsonpath expression value is not present // Also you can write you assert. AssertBody(asserts ...AssertBody) ExpectHTTPBuilder // RequireBody implements the same assertions as the `AssertBody`, but stops test execution when a test fails. RequireBody(asserts ...AssertBody) ExpectHTTPBuilder // OptionalAssertBody is not a mandatory assert. // Mark in allure as Skipped OptionalAssertBody(asserts ...AssertBody) ExpectHTTPBuilder // BrokenAssertBody is function for validate response, if it's failed, then test will be Broken. // Mark in allure as Broken BrokenAssertBody(asserts ...AssertBody) ExpectHTTPBuilder // AssertBodyT is function for validate response body with help testing.TB and allure allureProvider. // You may create allure step inside assert, add attachment, log information, etc. AssertBodyT(asserts ...AssertBodyT) ExpectHTTPBuilder // RequireBodyT implements the same assertions as the `AssertBodyT`, but stops test execution when a test fails. RequireBodyT(asserts ...AssertBodyT) ExpectHTTPBuilder // OptionalAssertBodyT is not a mandatory assert. // Mark in allure as Skipped OptionalAssertBodyT(asserts ...AssertBodyT) ExpectHTTPBuilder // BrokenAssertBodyT is function for validate response, if it's failed, then test will be Broken. // Mark in allure as Broken BrokenAssertBodyT(asserts ...AssertBodyT) ExpectHTTPBuilder // AssertHeaders is function for validate response headers // Available asserts from asserts/headers/headers.go: // Present is a function to asserts header is present // NotPresent is a function to asserts header is present // Also you can write you assert. AssertHeaders(asserts ...AssertHeaders) ExpectHTTPBuilder // RequireHeaders implements the same assertions as the `AssertHeaders`, but stops test execution when a test fails. RequireHeaders(asserts ...AssertHeaders) ExpectHTTPBuilder // OptionalAssertHeaders is not a mandatory assert. // Mark in allure as Skipped OptionalAssertHeaders(asserts ...AssertHeaders) ExpectHTTPBuilder // BrokenAssertHeaders is function for validate response, if it's failed, then test will be Broken. // Mark in allure as Broken BrokenAssertHeaders(asserts ...AssertHeaders) ExpectHTTPBuilder // AssertHeadersT is function for validate headers body with help testing.TB and allure allureProvider. // You may create allure step inside assert, add attachment, log information, etc. AssertHeadersT(asserts ...AssertHeadersT) ExpectHTTPBuilder // RequireHeadersT implements the same assertions as the `AssertHeadersT`, but stops test execution when a test fails. RequireHeadersT(asserts ...AssertHeadersT) ExpectHTTPBuilder // OptionalAssertHeadersT is not a mandatory assert. // Mark in allure as Skipped OptionalAssertHeadersT(asserts ...AssertHeadersT) ExpectHTTPBuilder // BrokenAssertHeadersT is function for validate response, if it's failed, then test will be Broken. // Mark in allure as Broken BrokenAssertHeadersT(asserts ...AssertHeadersT) ExpectHTTPBuilder // AssertResponse is function for validate response. AssertResponse(asserts ...AssertResponse) ExpectHTTPBuilder // RequireResponse implements the same assertions as the `AssertResponse`, but stops test execution when a test fails. RequireResponse(asserts ...AssertResponse) ExpectHTTPBuilder // OptionalAssertResponse is not a mandatory assert. // Mark in allure as Skipped OptionalAssertResponse(asserts ...AssertResponse) ExpectHTTPBuilder // BrokenAssertResponse is function for validate response, if it's failed, then test will be Broken. // Mark in allure as Broken BrokenAssertResponse(asserts ...AssertResponse) ExpectHTTPBuilder // AssertResponseT is function for validate response with help testing.TB. // You may create allure step inside assert, add attachment, log information, etc. AssertResponseT(asserts ...AssertResponseT) ExpectHTTPBuilder // RequireResponseT implements the same assertions as the `AssertResponseT`, but stops test execution when a test fails. RequireResponseT(asserts ...AssertResponseT) ExpectHTTPBuilder // OptionalAssertResponseT is not a mandatory assert. // Mark in allure as Skipped OptionalAssertResponseT(asserts ...AssertResponseT) ExpectHTTPBuilder // BrokenAssertResponseT is function for validate response, if it's failed, then test will be Broken. // Mark in allure as Broken BrokenAssertResponseT(asserts ...AssertResponseT) ExpectHTTPBuilder After ControlTest }
ExpectHTTPBuilder is a scope of methods for validate http response
type ExpectJSONSchema ¶ added in v0.1.6
ExpectJSONSchema is structs with JSON politics for response
type File ¶ added in v0.1.10
File is struct for upload file in form field If you set Path, file will read from file system If you set Name and Body, file will set from this fields
type HTTPTestMaker ¶
type HTTPTestMaker struct {
// contains filtered or unexported fields
}
HTTPTestMaker is a creator tests
func NewHTTPTestMaker ¶
func NewHTTPTestMaker(opts ...Option) *HTTPTestMaker
NewHTTPTestMaker is function for set options for all cute. For example, you can set timeout for all requests or set custom http client Options: - WithCustomHTTPTimeout - set timeout for all requests - WithHTTPClient - set custom http client - WithCustomHTTPRoundTripper - set custom http round tripper - WithJSONMarshaler - set custom json marshaler - WithMiddlewareAfter - set function which will run AFTER test execution - WithMiddlewareAfterT - set function which will run AFTER test execution with TB - WithMiddlewareBefore - set function which will run BEFORE test execution - WithMiddlewareBeforeT - set function which will run BEFORE test execution with TB
func (*HTTPTestMaker) NewTestBuilder ¶
func (m *HTTPTestMaker) NewTestBuilder() AllureBuilder
NewTestBuilder is a function for initialization foundation for cute
type JSONMarshaler ¶ added in v0.1.17
JSONMarshaler is marshaler which use for marshal/unmarshal JSON to/from struct
type Middleware ¶
type Middleware struct { After []AfterExecute AfterT []AfterExecuteT Before []BeforeExecute BeforeT []BeforeExecuteT }
Middleware is struct for executeInsideAllure something before or after test
type MiddlewareRequest ¶ added in v0.1.6
type MiddlewareRequest interface { RequestHTTPBuilder BeforeTest AfterTest }
MiddlewareRequest is function for create requests or add After/Before functions
type MiddlewareTable ¶ added in v0.1.6
type MiddlewareTable interface { TableTest BeforeTest AfterTest }
MiddlewareTable is functions for create table Test
type NextTestBuilder ¶ added in v0.1.6
type NextTestBuilder interface { AfterTestExecute CreateBuilder }
NextTestBuilder is a scope of methods for processing response, after Test.
type Option ¶
type Option func(*options)
Option ...
func WithCustomHTTPRoundTripper ¶
func WithCustomHTTPRoundTripper(r http.RoundTripper) Option
WithCustomHTTPRoundTripper is a function for set custom http round tripper
func WithCustomHTTPTimeout ¶
WithCustomHTTPTimeout is a function for set custom http client timeout
func WithHTTPClient ¶
WithHTTPClient is a function for set custom http client
func WithJSONMarshaler ¶ added in v0.1.17
func WithJSONMarshaler(m JSONMarshaler) Option
WithJSONMarshaler is a function for set custom json marshaler
func WithMiddlewareAfter ¶ added in v0.1.10
func WithMiddlewareAfter(after ...AfterExecute) Option
WithMiddlewareAfter is function for set function which will run AFTER test execution
func WithMiddlewareAfterT ¶ added in v0.1.10
func WithMiddlewareAfterT(after ...AfterExecuteT) Option
WithMiddlewareAfterT is function for set function which will run AFTER test execution
func WithMiddlewareBefore ¶ added in v0.1.10
func WithMiddlewareBefore(before ...BeforeExecute) Option
WithMiddlewareBefore is function for set function which will run BEFORE test execution
func WithMiddlewareBeforeT ¶ added in v0.1.10
func WithMiddlewareBeforeT(beforeT ...BeforeExecuteT) Option
WithMiddlewareBeforeT is function for set function which will run BEFORE test execution
type Request ¶ added in v0.1.6
type Request struct { Base *http.Request Builders []RequestBuilder Repeat *RequestRepeatPolitic }
Request is struct with HTTP request. You may use your *http.Request or create new with help Builders
type RequestBuilder ¶ added in v0.1.6
type RequestBuilder func(o *requestOptions)
RequestBuilder is a function for set options in request
type RequestHTTPBuilder ¶
type RequestHTTPBuilder interface { // Request is function for set http.Request Request(r *http.Request) ExpectHTTPBuilder // RequestBuilder is function for set http.Request with builders // Available builders: // WithMethod // WithURL // WithHeaders // WithHeadersKV // WithBody // WithMarshalBody // WithBody // WithURI // WithQuery // WithQueryKV // WithFileForm // WithFileFormKV // WithForm // WithFormKV RequestBuilder(r ...RequestBuilder) ExpectHTTPBuilder RequestParams }
RequestHTTPBuilder is a scope of methods to create HTTP requests
type RequestParams ¶ added in v0.1.6
type RequestParams interface { // RequestRepeat is a function for set options in request // if response.Code != Expect.Code, than request will repeat counts with delay. // Default delay is 1 second. RequestRepeat(count int) RequestHTTPBuilder // RequestRepeatDelay set delay for request repeat. // if response.Code != Expect.Code, than request will repeat counts with delay. // Default delay is 1 second. RequestRepeatDelay(delay time.Duration) RequestHTTPBuilder // RequestRepeatPolitic is a politic for repeat request. // if response.Code != Expect.Code, than request will repeat counts with delay. // if Optional is true and request is failed, than test step allure will be skipped, and t.Fail() will not execute. // If Broken is true and request is failed, than test step allure will be broken, and t.Fail() will execute. RequestRepeatPolitic(politic *RequestRepeatPolitic) RequestHTTPBuilder // RequestRepeatOptional is a option politic for repeat request. // if Optional is true and request is failed, than test step allure will be skipped, and t.Fail() will not execute. RequestRepeatOptional(optional bool) RequestHTTPBuilder // RequestRepeatBroken is a broken politic for repeat request. // If Broken is true and request is failed, than test step allure will be broken, and t.Fail() will execute. RequestRepeatBroken(broken bool) RequestHTTPBuilder }
RequestParams is a scope of methods to configure request
type RequestRepeatPolitic ¶ added in v0.1.6
RequestRepeatPolitic is struct for repeat politic if Optional is true and request is failed, than test step allure will be skip, and t.Fail() will not execute. If Broken is true and request is failed, than test step allure will be broken, and t.Fail() will not execute. If Optional and Broken is false, than test step will be failed, and t.Fail() will execute. If response.Code != Expect.Code, than request will repeat Count counts with Delay delay.
type ResultState ¶ added in v0.1.17
type ResultState int
ResultState is state of test
const ( ResultStateSuccess ResultState = iota ResultStateBroken ResultStateFail )
ResultState is state of test
type ResultsHTTPBuilder ¶
type ResultsHTTPBuilder interface { // GetHTTPResponse is a function, which returns http response GetHTTPResponse() *http.Response // GetErrors is a function, which returns all errors from test GetErrors() []error // GetName is a function, which returns name of Test GetName() string // GetResultState is a function, which returns state of test // State could be ResultStateSuccess, ResultStateBroken, ResultStateFail GetResultState() ResultState }
ResultsHTTPBuilder is a scope of methods for processing results
type T ¶
type T interface {
// contains filtered or unexported methods
}
T is internal testing.T provider
type TableTest ¶ added in v0.1.6
type TableTest interface { // PutNewTest is function for put request and assert for table Test PutNewTest(name string, r *http.Request, expect *Expect) TableTest // PutTests is function for put requests and asserts for table Test PutTests(params ...*Test) TableTest ControlTest }
TableTest is function for put request and assert for table tests
type Test ¶ added in v0.1.6
type Test struct { Name string AllureStep *AllureStep Middleware *Middleware Request *Request Expect *Expect // contains filtered or unexported fields }
Test is a main struct of test. You may field Request and Expect for create simple test
Source Files ¶
- allure.go
- assert.go
- assert_broken.go
- assert_optional.go
- assert_require.go
- assert_trace.go
- builder.go
- builder_allure.go
- builder_asserts.go
- builder_middleware.go
- builder_option.go
- builder_request.go
- builder_table.go
- cute.go
- init.go
- interface.go
- json_marshaler.go
- jsonschema.go
- logger.go
- provider.go
- request.go
- result.go
- roundtripper.go
- step.go
- test.go