Documentation ΒΆ
Overview ΒΆ
Package apicontext defines common step definitions for testing REST APIs using Cucumber and Godog
Index ΒΆ
- type ApiContext
- func (ctx *ApiContext) ISendRequestTo(method, uri string) error
- func (ctx *ApiContext) ISendRequestToWithBody(method, uri string, requestBody *godog.DocString) error
- func (ctx *ApiContext) ISendRequestToWithFormBody(method, uri string, requestBodyTable *godog.Table) error
- func (ctx *ApiContext) ISetHeaderWithValue(name string, value string) error
- func (ctx *ApiContext) ISetHeadersTo(dt *godog.Table) error
- func (ctx *ApiContext) ISetQueryParamWithValue(name string, value string) error
- func (ctx *ApiContext) ISetQueryParamsTo(dt *godog.Table) error
- func (ctx *ApiContext) InitializeScenario(s *godog.ScenarioContext)
- func (ctx *ApiContext) ReplaceScopeVariables(data string) string
- func (ctx *ApiContext) StoreJsonPathValue(pathExpr string, scopeKeyName string) error
- func (ctx *ApiContext) StoreResponseHeader(name string, scopeKeyName string) error
- func (ctx *ApiContext) StoreScopeData(scopeKeyName string, value string) error
- func (ctx *ApiContext) TheJSONPathHaveCount(pathExpr string, expectedCount int) error
- func (ctx *ApiContext) TheJSONPathShouldBePresent(pathExpr string) error
- func (ctx *ApiContext) TheJSONPathShouldHaveValue(pathExpr string, expectedValue string) error
- func (ctx *ApiContext) TheJSONPathShouldMatch(pathExpr string, pattern string) error
- func (ctx *ApiContext) TheResponseBodyShouldContain(s string) error
- func (ctx *ApiContext) TheResponseBodyShouldMatch(pattern string) error
- func (ctx *ApiContext) TheResponseCodeShouldBe(statusCode int) error
- func (ctx *ApiContext) TheResponseHeaderShouldHaveValue(name string, expectedValue string) error
- func (ctx *ApiContext) TheResponseShouldBeAValidJSON() error
- func (ctx *ApiContext) TheResponseShouldMatchJSON(body *godog.DocString) error
- func (ctx *ApiContext) TheResponseShouldMatchJsonSchema(path string) error
- func (ctx *ApiContext) TheScopeVariableShouldHaveValue(scopeKeyName string, expectedValue string) error
- func (ctx *ApiContext) WaitForSomeTime(timeToWait int) error
- func (ctx *ApiContext) WithBaseURL(url string) *ApiContext
- func (ctx *ApiContext) WithDebug(debug bool) *ApiContext
- func (ctx *ApiContext) WithJSONSchemasPath(path string) *ApiContext
- type ApiResponse
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
This section is empty.
Types ΒΆ
type ApiContext ΒΆ
type ApiContext struct {
// contains filtered or unexported fields
}
ApiContext main struct
func (*ApiContext) ISendRequestTo ΒΆ
func (ctx *ApiContext) ISendRequestTo(method, uri string) error
ISendRequestTo Sends a request to the specified endpoint using the specified method.
func (*ApiContext) ISendRequestToWithBody ΒΆ
func (ctx *ApiContext) ISendRequestToWithBody(method, uri string, requestBody *godog.DocString) error
ISendRequestToWithBody Send a request with json body. Ex: a POST request.
func (*ApiContext) ISendRequestToWithFormBody ΒΆ
func (ctx *ApiContext) ISendRequestToWithFormBody(method, uri string, requestBodyTable *godog.Table) error
ISendRequestToWithFormBody Send a request with json body. Ex: a POST request.
func (*ApiContext) ISetHeaderWithValue ΒΆ
func (ctx *ApiContext) ISetHeaderWithValue(name string, value string) error
ISetHeaderWithValue Step that add a new header to the current request.
func (*ApiContext) ISetHeadersTo ΒΆ
func (ctx *ApiContext) ISetHeadersTo(dt *godog.Table) error
ISetHeadersTo This step sets the request headers using a datatable as source. It allows to define multiple headers at the same time.
func (*ApiContext) ISetQueryParamWithValue ΒΆ
func (ctx *ApiContext) ISetQueryParamWithValue(name string, value string) error
ISetQueryParamWithValue Adds a new query param to the request
func (*ApiContext) ISetQueryParamsTo ΒΆ
func (ctx *ApiContext) ISetQueryParamsTo(dt *godog.Table) error
ISetQueryParamsTo Set query params from a Data Table
func (*ApiContext) InitializeScenario ΒΆ
func (ctx *ApiContext) InitializeScenario(s *godog.ScenarioContext)
InitializeScenario this function should be called when starting the Test suite, to register the available steps.
func (*ApiContext) ReplaceScopeVariables ΒΆ
func (ctx *ApiContext) ReplaceScopeVariables(data string) string
func (*ApiContext) StoreJsonPathValue ΒΆ
func (ctx *ApiContext) StoreJsonPathValue(pathExpr string, scopeKeyName string) error
StoreJsonPathValue Store value from json body path to scope map.
func (*ApiContext) StoreResponseHeader ΒΆ
func (ctx *ApiContext) StoreResponseHeader(name string, scopeKeyName string) error
StoreResponseHeader Store header value to scope map.
func (*ApiContext) StoreScopeData ΒΆ
func (ctx *ApiContext) StoreScopeData(scopeKeyName string, value string) error
StoreScopeData Store data in scope map.
func (*ApiContext) TheJSONPathHaveCount ΒΆ
func (ctx *ApiContext) TheJSONPathHaveCount(pathExpr string, expectedCount int) error
TheJSONPathHaveCount Validates if the field at the specified json path have the expected length
func (*ApiContext) TheJSONPathShouldBePresent ΒΆ
func (ctx *ApiContext) TheJSONPathShouldBePresent(pathExpr string) error
TheJSONPathShouldBePresent checks if the specified json path exists in the response body
func (*ApiContext) TheJSONPathShouldHaveValue ΒΆ
func (ctx *ApiContext) TheJSONPathShouldHaveValue(pathExpr string, expectedValue string) error
TheJSONPathShouldHaveValue Validates if the json object have the expected value at the specified path.
func (*ApiContext) TheJSONPathShouldMatch ΒΆ
func (ctx *ApiContext) TheJSONPathShouldMatch(pathExpr string, pattern string) error
TheJSONPathShouldMatch Validates Checks if the the value from the specified json path matches the specified pattern.
func (*ApiContext) TheResponseBodyShouldContain ΒΆ
func (ctx *ApiContext) TheResponseBodyShouldContain(s string) error
TheResponseBodyShouldContain Checks if the response body contains the specified string
func (*ApiContext) TheResponseBodyShouldMatch ΒΆ
func (ctx *ApiContext) TheResponseBodyShouldMatch(pattern string) error
TheResponseBodyMatch Checks if the response body matches the specified pattern
func (*ApiContext) TheResponseCodeShouldBe ΒΆ
func (ctx *ApiContext) TheResponseCodeShouldBe(statusCode int) error
TheResponseCodeShouldBe Check if the http status code of the response matches the specified value.
func (*ApiContext) TheResponseHeaderShouldHaveValue ΒΆ
func (ctx *ApiContext) TheResponseHeaderShouldHaveValue(name string, expectedValue string) error
TheResponseHeaderShouldHaveValue Verify the value of a response header
func (*ApiContext) TheResponseShouldBeAValidJSON ΒΆ
func (ctx *ApiContext) TheResponseShouldBeAValidJSON() error
TheResponseShouldBeAValidJSON checks if the response is a valid JSON.
func (*ApiContext) TheResponseShouldMatchJSON ΒΆ
func (ctx *ApiContext) TheResponseShouldMatchJSON(body *godog.DocString) error
TheResponseShouldMatchJSON Check that response matches the expected JSON.
func (*ApiContext) TheResponseShouldMatchJsonSchema ΒΆ
func (ctx *ApiContext) TheResponseShouldMatchJsonSchema(path string) error
TheResponseShouldMatchJsonSchema Checks if the response matches the specified JSON schema
func (*ApiContext) TheScopeVariableShouldHaveValue ΒΆ
func (ctx *ApiContext) TheScopeVariableShouldHaveValue(scopeKeyName string, expectedValue string) error
TheScopeVariableShouldHaveValue Verify the value of a scope variable
func (*ApiContext) WaitForSomeTime ΒΆ
func (ctx *ApiContext) WaitForSomeTime(timeToWait int) error
WaitForSomeTime halt for some time.
func (*ApiContext) WithBaseURL ΒΆ
func (ctx *ApiContext) WithBaseURL(url string) *ApiContext
WithBaseURL Configures context base URL
func (*ApiContext) WithDebug ΒΆ
func (ctx *ApiContext) WithDebug(debug bool) *ApiContext
WithDebug Configures debug mode
func (*ApiContext) WithJSONSchemasPath ΒΆ
func (ctx *ApiContext) WithJSONSchemasPath(path string) *ApiContext
WithJSONSchemasPath Specifies the path to JSON schema files for doing response validation