QA Guides

Abstraction

Methods overview:

1. PrerequisiteSteps

Takes steps from the provided TestDefinition, marks all of them as prerequisites, and appends them to this test. A step marked as prerequisite ends in 'Blocked' state instead of 'Failed' state when it fails. This step is executed immediately when tests are being constructed and it will not be present in results.

Parameters:

  • TestDefinition test - The test from which steps will be copied over.

Example of method call:

RestTestBuilder
    .CreateTest("Localhost")
    .PrerequisiteSteps(_userContactInfoTests.SetUserId());

2. ReuseTest

Takes steps from the provided TestDefinition and appends them to this test, effectively reusing steps of test cases without the need to manually copy-paste their steps. This step is executed immediately when tests are being constructed and it will not be present in results.

Parameters:

  • TestDefinition test - The test from which steps will be copied over.
  • int? startStepIndex = null - Optionally specify from which step should copying begin. Starts from the beginning when null. Uses one-based indexing.
  • int? endStepIndex = null - Optionally specify at which step should copying end. Copies till the end of the list when null. Uses one-based indexing.
  • bool isPrerequisite = false - When true, all copied steps will be marked as prerequisites. A step marked as prerequisite ends in 'Blocked' state instead of 'Failed' state when it fails.

Example of method call:

RestTestBuilder
    .CreateTest("Localhost")
    .ReuseTest(_userContactInfoTests.SetUserId(), isPrerequisite: true);

Authentication

Methods overview:

1. Authenticate

Parameters:

  • string providerName
  • string user
  • bool isPrerequisite = false
  • string label = ""

Example of method call:

RestTestBuilder
    .CreateTest("Localhost")
    .Authenticate("KeycloakTokenProvider", "test-web");

2. SetAuthBearerToken

Finds a runtime variable with the name variableName and sets its value as an auth header in the form of Authorization: Bearer value for following requests. If variableName is null, then auth token is clearer from cache.

Parameters:

  • string? variableName - Name of the variable whose value will be used as an auth token.
  • string label = "" - Custom name for the step that will be shown in report.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • ReportStepOption options = ReportStepOption.DoNotReport - Sets whether this step should appear in results.

Example of method call:

RestTestBuilder
    .CreateTest("Localhost")
    .SetAuthBearerToken(AuthToken);

3. SetAuthEnvironmentKey

Sets environment key provided by newKey as auth header in form of X-Environment-Key: value for following requests.

Parameters:

  • Func<TestVariables, string?> newKey - Function providing environment key.
  • string label = "" - Custom name for the step that will be shown in report.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • ReportStepOption options = ReportStepOption.DoNotReport - Sets whether this step should appear in results.

4. SetAuthSoapCredentials

Sets provided userName and password into username client credentials for following soap requests.

Parameters:

  • string? userName - The value that will be used as username in the authentication process.
  • string? password - The value that will be used as password in the authentication process.
  • string label = "" - Custom name for the step that will be shown in report.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • ReportStepOption options = ReportStepOption.DoNotReport - Sets whether this step should appear in results.

Example of method call:

RestTestBuilder
    .CreateTest("Localhost")
    .SetAuthSoapCredentials("JohnDoe", "Password123");

5. SetAuthSoapCredentialsFromVariables

Finds runtime variables with name userNameVariable and passwordVariable, and sets their values into username client credentials for following soap requests.

Parameters:

  • string userNameVariable - Name of variable whose value will be used as username in the authentication process.
  • string passwordVariable - Name of variable whose value will be used as password in the authentication process.
  • string label = "" - Custom name for the step that will be shown in report.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • ReportStepOption options = ReportStepOption.DoNotReport - Sets whether this step should appear in results

6. SetAuthToken

Finds runtime variable with name variableName and sets its value as auth header in form of Authorization: value for following requests. If variableName is null, then auth token is cleared from cache.

Parameters:

  • string? variableName - Name of variable whose value will be used as auth token.
  • string label = "" - Custom name for the step that will be shown in report.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • ReportStepOption options = ReportStepOption.DoNotReport - Sets whether this step should appear in results.

Example of method call:

RestTestBuilder
    .CreateTest("Localhost")
    .SetAuthToken(AuthToken);

7. SetAuthXMsalToken

Finds runtime variable with name variableName and sets its value as auth header in form of x-msal-access-token: value for following requests. If variableName is null, then auth token is cleared from cache.

Parameters:

  • string? variableName - Name of variable whose value will be used as auth token.
  • string label = "" - Custom name for the step that will be shown in report.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • ReportStepOption options = ReportStepOption.DoNotReport - Sets whether this step should appear in results.

Caching

Methods overview:

1. DeclareRuntimeVariable

Keeps track of a value by assigning it a unique name. Storing another value under same name will overwrite previous value. By default each test case has its own variable storage. It is possible set variable as global, in which case it will be stored in global cache and will be accessible from all test cases. Test suite prehook always starts with empty local cache, but its variables will be passed to test case prehooks and from them to test cases. Test case posthooks take over variables from their respective test cases. Test suite posthook has access to all variables defined by all test cases from the given test suite.

Parameters:

  • string key - Name / identifier under which value will be stored.
  • object variable - The value to be stored.
  • ReportStepOption options = ReportStepOption.DoNotReport - Sets whether this step should appear in results.
  • bool asGlobalVariable = false - When true, value will be stored under the given name in global cache, which is accessible by all loaded test cases.
  • string label = "" - Custom name for the step that will be shown in report.

Example of method call:

RestTestBuilder
    .CreateTest("Localhost")
    .DeclareRuntimeVariable("ABC", 44);

2. DeclareRuntimeVariable (with function)

Keeps track of a value by assigning it a unique name. Storing another value under same name will overwrite previous value. By default each test case has its own variable storage. It is possible set variable as global, in which case it will be stored in global cache and will be accessible from all test cases. Test suite prehook always starts with empty local cache, but its variables will be passed to test case prehooks and from them to test cases. Test case posthooks take over variables from their respective test cases. Test suite posthook has access to all variables defined by all test cases from the given test suite.

Parameters:

  • string key - Name / identifier under which value will be stored.
  • Func<TestVariables, object> variable - A function that returns the value to be stored.
  • ReportStepOption options = ReportStepOption.DoNotReport - Sets whether this step should appear in results.
  • bool asGlobalVariable = false - When true, value will be stored under the given name in global cache, which is accessible by all loaded test cases.
  • string label = "" - Custom name for the step that will be shown in report.

3. SaveJsonChildrenCount

Find object in response body of latest HTTP request under path given by jsonPath, determines how many child items the object has, and stores that count as a runtime variable.

Parameters:

  • string key - The name of the variable under which child count will be stored.
  • string jsonPath - The path in response body where the object can be found.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • bool asGlobalVariable = false - When true, value will be stored under given name in global cache, which is accessible by all loaded test cases.
  • string label = "" - Custom name for the step that will be shown in the report.

4. SaveJsonVariable

Find value in response body of latest HTTP request under path given by jsonPath and stores it as a runtime variable.

Parameters:

  • string key - The name of the variable under which the extracted value will be stored.
  • string jsonPath - The path in response body where the value can be found.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • bool asGlobalVariable = false - When true, value will be stored under given name in global cache, which is accessible by all loaded test cases.
  • bool ignoreEmpty = false - When true, the step will complete even if the value has not been found. Otherwise, the step will fail.
  • string label = "" - Custom name for the step that will be shown in the report.

Example of method call:

RestTestBuilder
    .CreateTest("Localhost")
    .SaveJsonVariable(RetAConstants.Cuid, "$.externalId");

5. SaveResponseContentVariable

Extract response content of the latest HTTP request as a string and stores it as a runtime variable.

Parameters:

  • string key - The name of the variable under which the extracted value will be stored.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • bool asGlobalVariable = false - When true, value will be stored under given name in global cache, which is accessible by all loaded test cases.
  • string label = "" - Custom name for the step that will be shown in the report.

6. SaveResponseContentVariable

Deserialize response content of the latest HTTP request into type T and stores that object as a runtime variable.

Parameters:

  • string key - The name of the variable under which the deserialized object will be stored.
  • bool ignoreMissingMembersDuringDeserialization = false - When true, missing members will be ignored. Otherwise, the step will fail.
  • IContractResolver? contractResolver = null - A custom resolver used during deserialization into the specified type.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • bool asGlobalVariable = false - When true, value will be stored under given name in global cache, which is accessible by all loaded test cases.
  • string label = "" - Custom name for the step that will be shown in the report.

7. SaveResponseHeaderVariable

Finds a header by name headerName in the response of the latest HTTP request and stores that header's value as a runtime variable.

Parameters:

  • string key - The name of the variable under which the response header value will be stored.
  • string headerName - Name of the header to look for in the response.
  • bool failStepIfHeaderNotFound = true - When true, the step will be marked as failed when the header is not present in the response.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • bool asGlobalVariable = false - When true, value will be stored under given name in global cache, which is accessible by all loaded test cases.
  • string label = "" - Custom name for the step that will be shown in the report.

8. SaveStringVariable

Takes the raw response content of the latest HTTP request and stores it as a runtime variable.

Parameters:

  • string key - The name of the variable under which the response content will be stored.
  • bool removeParentheses = false - When true, removes outer-most parentheses from the value.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • bool asGlobalVariable = false - When true, value will be stored under given name in global cache, which is accessible by all loaded test cases.
  • string label = "" - Custom name for the step that will be shown in the report.

Configuration

Methods overview:

1. ChangeHost

Configures which host should be the default target for following http requests.

Parameters:

  • string hostName - Name of the host as seen in configuration.
  • ReportStepOption options = ReportStepOption.DoNotReport - Sets whether this step should appear in results.
  • string label = "" - Custom name for the step that will be shown in report.

Example of method call:

RestTestBuilder
    .CreateTest("Localhost")
    .ChangeHost(HostConstants.SelfCareHostKey);

2. SetThinkTime

Configures think time. Think time is randomly selected value between configured min and max values, used as delay before sending http requests. Simulates users who need to think a bit before taking action.

Parameters:

  • bool enabled - When true, enables the think time mechanism for following requests, otherwise disables the mechanism.
  • int? min = null - Minimum think time delay in milliseconds.
  • int? max = null - Maximum think time delay in milliseconds.
  • string label = "" - Custom name for the step that will be shown in report.

3. SetRequestTimeout (int)

Sets new timeout for all following http requests.

Parameters:

  • int timeout - New timeout value in milliseconds.
  • string label = "" - Custom name for the step that will be shown in report.

4. SetRequestTimeout (TimeSpan)

Sets new timeout for all following http requests.

Parameters:

  • TimeSpan timeout - New timeout value.
  • string label = "" - Custom name for the step that will be shown in report.

5. RestorePreviousRequestTimeout

Reverts back to previous timeout value for http requests. Should be used only after SetRequestTimeout step was called earlier in the test case.

Parameters:

  • string label = "" - Custom name for the step that will be shown in report.

Flow Control

Methods overview:

1. For

Repeatedly executes substeps provided by actions a set number of times.

Parameters:

  • int numberOfIterations - How many iterations will be executed.
  • Action<RestTestBuilder> actions - A list of substeps to execute.
  • bool breakAtFirstIssue = false - When false, starts a new iteration if the current iteration of substeps did not end successfully. Otherwise, immediately breaks the loop.
  • string label = "" - Custom name for the step that will be shown in report.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.

2. ForEach

Executes substeps provided by actions for each row in the specified data table. The value in the current iteration can be accessed from substeps via ITestRuntimeState.CurrentIterationItem.

Parameters:

  • string collectionVariableName - Name of a runtime variable whose value will be iterated over. Value must be of type ICollection.
  • string label - Custom name for the step that will be shown in report.
  • Action<RestTestBuilder> actions - A list of substeps to execute.
  • bool breakAtFirstIssue = false - When false, starts a new iteration if the current iteration of substeps did not end successfully. Otherwise, immediately breaks the loop.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.

3. ForEachDataTableRow

Executes substeps provided by actions for each row in the specified data table. The value in the current iteration can be accessed from substeps via ITestRuntimeState.CurrentIterationItem.

Parameters:

  • string dataTableVariableName - Name of a runtime variable whose value will be iterated over. Value must be of type DataTable.
  • string label - Custom name for the step that will be shown in report.
  • Action<RestTestBuilder> actions - A list of substeps to execute.
  • bool breakAtFirstIssue = false - When false, starts a new iteration if the current iteration of substeps did not end successfully. Otherwise, immediately breaks the loop.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.

4. ForEachVariableValue

Executes substeps provided by actions for each variable named variableName. The value in the current iteration can be accessed from substeps via ITestRuntimeState.CurrentIterationItem. NOTE: Multiple variables with same name only appear in test case posthooks and test suite posthooks. For all other cases there will only ever be a single variable of given name.

Parameters:

  • string variableName - Name of the variable. There is no type check; each value will be loaded as object.
  • string label - Custom name for the step that will be shown in report.
  • Action<RestTestBuilder> actions - A list of substeps to execute.
  • bool breakAtFirstIssue = false - When false, starts a new iteration if the current iteration of substeps did not end successfully. Otherwise, immediately breaks the loop.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.

5. ForParallel

Executes substeps provided in actions multiple times in parallel. If durationSec is greater than zero, then each iteration is executed after a short delay.

Parameters:

  • int numberOfIterations - How many times in parallel should substeps be executed.
  • int durationSec - Represents total time over which all iterations should be started. The actual delay between each iteration is calculated as durationSec / numberOfIterations. If the value is zero, all iterations are started immediately.
  • Action<RestTestBuilder> actions - A list of substeps to execute.
  • string label = "" - Custom name for the step that will be shown in report.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.

6. Wait (int)

Blocks test execution for the specified amount of time.

Parameters:

  • int milliseconds - The duration of the wait in milliseconds.
  • string label - Custom name for the step that will be shown in report.
  • ReportStepOption options = ReportStepOption.DoNotReport - Sets whether this step should appear in results.

Example of method call:

RestTestBuilder
    .CreateTest("Localhost")
    .Wait(3000);

7. Wait (TimeSpan)

Blocks test execution for the specified amount of time.

Parameters:

  • TimeSpan timespan - The duration of the wait.
  • string label - Custom name for the step that will be shown in report.
  • ReportStepOption options = ReportStepOption.DoNotReport - Sets whether this step should appear in results.

8. While

Repeatedly executes at runtime the provided condition and if evaluated as true, runs a list of substeps provided in actions.

Parameters:

  • Func<ITestRuntimeState, bool> condition - A function evaluated at runtime that determines if the loop will start the next iteration or not.
  • int maxIterations - Configures the maximum number of iterations before the step is marked as failed.
  • Action<RestTestBuilder> actions - A list of substeps to execute when condition is evaluated to true.
  • string label = "" - Custom name for the step that will be shown in report.
  • bool breakAtFirstIssue = false - When false, starts a new iteration if the current iteration of substeps did not end successfully. Otherwise, immediately breaks the loop.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.

9. DoWhile

Executes a list of substeps provided in actions at least once and continues repeatedly executing them as long as the provided condition evaluates as true. NOTE: There is currently hard-coded a limit of 1000 iterations.

Parameters:

  • Func<ITestRuntimeState, bool> condition - A function evaluated at runtime that determines if the loop will start the next iteration or not.
  • int maxIterations - Configures the maximum number of iterations before the step is marked as failed. NOTE: There is currently hard-coded a limit of 1000 iterations.
  • Action<RestTestBuilder> actions - A list of substeps to execute when condition is evaluated to true.
  • string label = "" - Custom name for the step that will be shown in report.
  • bool breakAtFirstIssue = false - When false, starts a new iteration if the current iteration of substeps did not end successfully. Otherwise, immediately breaks the loop.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.

10. If

A conditional step that evaluates the provided condition during runtime. If evaluated as true, substeps specified in actions will be executed.

Parameters:

  • Func<ITestRuntimeState, bool> condition - A function evaluated at runtime that returns a boolean value. When the returned value is true, substeps will be executed; otherwise, they are skipped.
  • Action<RestTestBuilder> actions - A list of substeps to execute when condition is evaluated to true.
  • string label = "" - Custom name for the step that will be shown in report.

Http

Methods overview:

1. SendRandomizedRequest

An advanced step that sends an HTTP request to the currently configured host. The request will randomly select one request body from randomBodyProviders and a randomly selected number of parameters from randomBodyProviders. These parameters can be headers, query parameters or parts of body in case of multipart or url-encoded requests.

Parameters:

  • Func<TestVariables, RestRequest> request - Function providing an object with details of the HTTP request.
  • List<Func<Random, List<Parameter>>> randomParamProviders - A list of functions, each function takes Random as input and returns a list of parameters that will be added to the request.
  • string label = "" - Custom name for the step that will be shown in report.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • bool isXTestEnabled = true - Allows overriding default behavior, where each SOAP request contains the header X-Test: true.
  • int noParamChance = -1 - Can specify the chance that no parameters will be added to the request. Allowed values: 0 ... < 95. Negative values mean this mechanism will not be used at all.
  • List<Func<object>>? randomBodyProviders = null - An optional list of functions that return the request body. When any has been provided, the request body will be selected at random from this list.
  • AuthType? authType = null - Optionally override the type of authentication used when sending the HTTP request. If null, the authentication type from the current host is used.
  • string? host = null - Optionally override to which host the request should be sent. If null, the currently configured host is used.

2. SendRequest

Sends an HTTP request to the currently configured host.

Parameters:

  • RestRequest request - An object with details of the HTTP request.
  • string label = "" - Custom name for the step that will be shown in report.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • bool isXTestEnabled = true - Allows overriding default behavior, where each SOAP request contains the header X-Test: true.
  • AuthType? authType = null - Optionally override the type of authentication used when sending the HTTP request. If null, the authentication type from the current host is used.
  • string? host = null - Optionally override to which host the request should be sent. If null, the currently configured host is used.

Example of method call:

RestTestBuilder
    .CreateTest("Localhost")
    .SendRequest(new RestRequest("/users")
                .AddQueryParameter("id", 10)
                .AddQueryParameter("id", 15)
                .AddQueryParameter("id", 7),
                label: "abc");

3. SendRequest (with function)

Sends an HTTP request to the currently configured host.

Parameters:

  • Func<TestVariables, RestRequest> request - Function providing an object with details of the HTTP request.
  • string label = "" - Custom name for the step that will be shown in report.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • bool isXTestEnabled = true - Allows overriding default behavior, where each SOAP request contains the header X-Test: true.
  • AuthType? authType = null - Optionally override the type of authentication used when sending the HTTP request. If null, the authentication type from the current host is used.
  • string? host = null - Optionally override to which host the request should be sent. If null, the currently configured host is used.

4. WaitForJsonValue (RestRequest)

Sends an http request and validates if json object found in response at specified jsonPath converted to string matches expectedJson. If not, waits at least minIterationDelay ms before resending the request again. Sends the request up to maxAttempts times before failing the step.

Parameters:

  • RestRequest request - An object with detail of http request.
  • string expectedJson - Expected json string.
  • string jsonPath - Json path used to extract json object from response body.
  • int maxAttempts = 10 - Up to how many times request will be sent before step fails.
  • int minIterationDelay = 500 - At least how many ms to wait before resending request.
  • string label = "" - Custom name for the step that will be shown in report.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • AuthType? authType = null - Optionally override the type of authentication used when sending http request. If null, the authentication type from current host is used.
  • string? host = null - Optionally override to which host should the request be sent. If null, the currently configured host is used.

5. WaitForJsonValue (Func<TestVariables, RestRequest>)

Sends an http request and validates if json object found in response at specified jsonPath converted to string matches expectedJson. If not, waits at least minIterationDelay ms before resending the request again. Sends the request up to maxAttempts times before failing the step.

Parameters:

  • Func<TestVariables, RestRequest> request - Function providing object with detail of http request.
  • string expectedJson - Expected json string.
  • string jsonPath - Json path used to extract json object from response body.
  • int maxAttempts = 10 - Up to how many times request will be sent before step fails.
  • int minIterationDelay = 500 - At least how many ms to wait before resending request.
  • string label = "" - Custom name for the step that will be shown in report.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • AuthType? authType = null - Optionally override the type of authentication used when sending http request. If null, the authentication type from current host is used.
  • string? host = null - Optionally override to which host should the request be sent. If null, the currently configured host is used.

6. WaitForStatusCode (RestRequest)

Sends an http request and validates if response status code matches expectedStatusCode. If not, waits at least minIterationDelay ms before resending the request again. Sends the request up to maxAttempts times before failing the step.

Parameters:

  • RestRequest request - An object with detail of http request.
  • int expectedStatusCode - Expected status code in response.
  • int maxAttempts = 10 - Up to how many times request will be sent before step fails.
  • int minIterationDelay = 500 - At least how many ms to wait before resending request.
  • string label = "" - Custom name for the step that will be shown in report.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • AuthType? authType = null - Optionally override the type of authentication used when sending http request. If null, the authentication type from current host is used.
  • string? host = null - Optionally override to which host should the request be sent. If null, the currently configured host is used.

7. WaitForStatusCode (Func<TestVariables, RestRequest>)

Sends an http request and validates if response status code matches expectedStatusCode. If not, waits at least minIterationDelay ms before resending the request again. Sends the request up to maxAttempts times before failing the step.

Parameters:

  • Func<TestVariables, RestRequest> request - Function providing object with detail of http request.
  • int expectedStatusCode - Expected status code in response.
  • int maxAttempts = 10 - Up to how many times request will be sent before step fails.
  • int minIterationDelay = 500 - At least how many ms to wait before resending request.
  • string label = "" - Custom name for the step that will be shown in report.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • AuthType? authType = null - Optionally override the type of authentication used when sending http request. If null, the authentication type from current host is used.
  • string? host = null - Optionally override to which host should the request be sent. If null, the currently configured host is used.

Soap

Methods overview:

1. SendSoapRequest

Sends a SOAP request via the specified WCF-generated client.

Parameters:

  • TServiceClient - An implementation of ClientBase TService.
  • TService - Interface containing soap endpoints.
  • string urlPart - URL part for targeting a specific SOAP endpoint.
  • Func<TServiceClient, TestVariables, Task<object>> request - Function providing an object representing the SOAP request body.
  • string responseVariable - Name of the runtime variable under which the response will be stored so that succeeding steps can access the response body.
  • string label = "" - Custom name for the step that will be shown in report.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • bool isXTestEnabled = true - Allows overriding default behavior, where each SOAP request contains the header X-Test: true.
  • AuthType? authType = null - Optionally override the type of authentication used when sending the HTTP request. If null, the authentication type from the current host is used.
  • string? host = null - Optionally override to which host the request should be sent. If null, the currently configured host is used.

2. SendSoapRequest (with Task)

Sends a SOAP request via the specified WCF-generated client.

Parameters:

  • TServiceClient - An implementation of ClientBase TService.
  • TService - Interface containing soap endpoints.
  • string urlPart - URL part for targeting a specific SOAP endpoint.
  • Func<TServiceClient, TestVariables, Task> request - Function preparing an object representing the SOAP request body.
  • string responseVariable - Name of the runtime variable under which the response will be stored so that succeeding steps can access the response body.
  • string label = "" - Custom name for the step that will be shown in report.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • bool isXTestEnabled = true - Allows overriding default behavior, where each SOAP request contains the header X-Test: true.
  • AuthType? authType = null - Optionally override the type of authentication used when sending the HTTP request. If null, the authentication type from the current host is used.
  • string? host = null - Optionally override to which host the request should be sent. If null, the currently configured host is used.

Utility

Methods overview:

1. ClearCookies

Parameters:

  • string host
  • string label = ""
  • ReportStepOption options = ReportStepOption.DoNotReport

2. ClearAllCookies

Parameters:

  • string label = ""
  • ReportStepOption options = ReportStepOption.DoNotReport

3. Execute (Task)

Executes arbitrary asynchronous code.

Parameters:

  • Task method - An asynchronous function containing arbitrary code.
  • string label = "" - Custom name for the step that will be shown in report.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.

4. Execute (Func<ITestRuntimeState, Task>)

Executes arbitrary asynchronous code. Input is an instance of the test itself.

Parameters:

  • Func<ITestRuntimeState, Task> method - An asynchronous function containing arbitrary code.
  • string label = "" - Custom name for the step that will be shown in report.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.

5. Execute (Action)

Executes arbitrary synchronous code. Input is an instance of the test itself.

Parameters:

  • Action<ITestRuntimeState> method - A synchronous function containing arbitrary code.
  • string label = "" - Custom name for the step that will be shown in report.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.

6. IgnoreCookies

Parameters:

  • string label = ""
  • ReportStepOption options = ReportStepOption.DoNotReport

7. Print

Prints a single string value into the debug console.

Parameters:

  • string message - A string value that will be written into the debug console.
  • string label = "" - Custom name for the step that will be shown in report.
  • ReportStepOption options = ReportStepOption.DoNotReport - Sets whether this step should appear in results.

8. Print (with function)

Prints a single string value into the debug console.

Parameters:

  • Func<ITestRuntimeState, string> message - A function providing a string value that will be written into the debug console.
  • string label = "" - Custom name for the step that will be shown in report.
  • ReportStepOption options = ReportStepOption.DoNotReport - Sets whether this step should appear in results.

Example of method call:

RestTestBuilder
    .CreateTest("Localhost")
    .Print(state => $"Stored variable value: {state.TestVariables["ABC"]}");

9. PrintArray

Prints a list of string values into the debug console.

Parameters:

  • string[] items - A list of strings that will be written into the debug console.
  • string label = "" - Custom name for the step that will be shown in report.
  • ReportStepOption options = ReportStepOption.DoNotReport - Sets whether this step should appear in results.

10. PrintArray (with function)

Prints a list of string values into the debug console.

Parameters:

  • Func<ITestRuntimeState, string[]> items - A function providing a list of strings that will be written into the debug console.
  • string label = "" - Custom name for the step that will be shown in report.
  • ReportStepOption options = ReportStepOption.DoNotReport - Sets whether this step should appear in results.

11. UseCookies

Parameters:

  • string label = ""
  • ReportStepOption options = ReportStepOption.DoNotReport

Verification

Methods overview:

1. VerifyJsonChildrenCount

Verifies that the value found in the response body of the latest HTTP request under the path given by jsonPath has exactly the expected number of child items.

Parameters:

  • int expected - The number of child items that the object found under the given JSON path must have.
  • string jsonPath - The path in the response body where the value-to-be-evaluated can be found.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • string label = "" - Custom name for the step that will be shown in the report.

Example of method call:

bool isPrerequisite = false
RestTestBuilder
    .CreateTest("Localhost")
    .VerifyJsonChildrenCount(0, "$.validationErrors", isPrerequisite);

2. VerifyJsonChildrenCountGreaterThan

Verifies that the value found in the response body of the latest HTTP request under the path given by jsonPath has more than the expected number of child items.

Parameters:

  • int expected - The number of child items that must be exceeded by the object found under the given JSON path.
  • string jsonPath - The path in the response body where the value-to-be-evaluated can be found.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • string label = "" - Custom name for the step that will be shown in the report.

3. VerifyJsonChildrenCountGreaterThanOrEqualTo

Verifies that the value found in the response body of the latest HTTP request under the path given by jsonPath has greater than or equal to the expected number of child items.

Parameters:

  • int expected - The minimal amount of child items that the object found under the given JSON path must have.
  • string jsonPath - The path in the response body where the value-to-be-evaluated can be found.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • string label = "" - Custom name for the step that will be shown in the report.

4. VerifyJsonVariableEquals (int)

Verifies that the value found in the response body of the latest HTTP request under the path given by jsonPath is equal to expected.

Parameters:

  • int expected - The value that should be found under the given JSON path.
  • string jsonPath - The path in the response body where the value-to-be-evaluated can be found.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • bool failOnNoMatch = false - If true, the step will fail if no value has been found under the given JSON path.
  • string label = "" - Custom name for the step that will be shown in the report.

5. VerifyJsonVariableEquals (string)

Verifies that the value found in the response body of the latest HTTP request under the path given by jsonPath is equal to expected.

Parameters:

  • string expected - The value that should be found under the given JSON path.
  • string jsonPath - The path in the response body where the value-to-be-evaluated can be found.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • bool failOnNoMatch = false - If true, the step will fail if no value has been found under the given JSON path.
  • string label = "" - Custom name for the step that will be shown in the report.

Example of method call:

bool isPrerequisite = false
RestTestBuilder
    .CreateTest("Localhost")
    .VerifyJsonVariableEquals(string.Empty, "$.errorCode", isPrerequisite);

6. VerifyJsonVariableEquals (Func<TestVariables, string>)

Verifies that the value found in the response body of the latest HTTP request under the path given by jsonPath is equal to the value provided by the function expected.

Parameters:

  • Func<TestVariables, string> expected - A function providing the value that should be found under the given JSON path.
  • string jsonPath - The path in the response body where the value-to-be-evaluated can be found.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • bool failOnNoMatch = false - If true, the step will fail if no value has been found under the given JSON path.
  • string label = "" - Custom name for the step that will be shown in the report.

7. VerifyJsonVariableEquals (double)

Verifies that the value found in the response body of the latest HTTP request under the path given by jsonPath is equal to expected.

Parameters:

  • double expected - The value that should be found under the given JSON path.
  • string jsonPath - The path in the response body where the value-to-be-evaluated can be found.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • bool failOnNoMatch = false - If true, the step will fail if no value has been found under the given JSON path.
  • string label = "" - Custom name for the step that will be shown in the report.

8. VerifyJsonVariableNotEquals (int)

Verifies that the value found in the response body of the latest HTTP request under the path given by jsonPath is not equal to unexpected.

Parameters:

  • int unexpected - The value that should not be found under the given JSON path.
  • string jsonPath - The path in the response body where the value-to-be-evaluated can be found.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • string label = "" - Custom name for the step that will be shown in the report.

9. VerifyJsonVariableNotEquals (double)

Verifies that the value found in the response body of the latest HTTP request under the path given by jsonPath is not equal to unexpected.

Parameters:

  • double unexpected - The value that should not be found under the given JSON path.
  • string jsonPath - The path in the response body where the value-to-be-evaluated can be found.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • string label = "" - Custom name for the step that will be shown in the report.

10. VerifyJsonVariableNotEquals (string)

Verifies that the value found in the response body of the latest HTTP request under the path given by jsonPath is not equal to unexpected.

Parameters:

  • string unexpected - The value that should not be found under the given JSON path.
  • string jsonPath - The path in the response body where the value-to-be-evaluated can be found.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • string label = "" - Custom name for the step that will be shown in the report.

11. VerifyJsonVariableNotEquals (Func<TestVariables, string>)

Verifies that the value found in the response body of the latest HTTP request under the path given by jsonPath is not equal to the value provided by the function unexpected.

Parameters:

  • Func<TestVariables, string> unexpected - A function providing the value that should not be found under the given JSON path.
  • string jsonPath - The path in the response body where the value-to-be-evaluated can be found.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • string label = "" - Custom name for the step that will be shown in the report.

12. VerifyResponseContains (Func<TestVariables, string>)

Verifies that the response body of the latest HTTP request contains the value provided by the function expected.

Parameters:

  • Func<TestVariables, string> expected - A function providing the value that should be present in the response body.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • string label = "" - Custom name for the step that will be shown in the report.

13. VerifyResponseContains (string)

Verifies that the response body of the latest HTTP request contains expected.

Parameters:

  • string expected - The value that should be present in the response body.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • string label = "" - Custom name for the step that will be shown in the report.

14. VerifyResponseNotContains (Func<TestVariables, string>)

Verifies that the response body of the latest HTTP request does not contain the value provided by the function unexpected.

Parameters:

  • Func<TestVariables, string> unexpected - A function providing the value that should not appear in the response body.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • string label = "" - Custom name for the step that will be shown in the report.

15. VerifyResponseNotContains (string)

Verifies that the response body of the latest HTTP request does not contain unexpected.

Parameters:

  • string unexpected - The value that should not appear in the response body.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • string label = "" - Custom name for the step that will be shown in the report.

16. VerifyResponseEqualsVariable

Verifies that the response body of the latest HTTP request is of type T and contains the same data as the object stored in runtime variables under the name key.

Parameters:

  • string key - Name of the runtime variable that contains the expected object.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • string label = "" - Custom name for the step that will be shown in the report.

17. VerifyResponseHeadersContains (Func<TestVariables, string>)

Verifies that the response of the latest HTTP request contains a header with the name provided by the function expected.

Parameters:

  • Func<TestVariables, string> expected - A function providing the header name that is expected in the HTTP response.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • string label = "" - Custom name for the step that will be shown in the report.

18. VerifyResponseHeadersContains (string)

Verifies that the response of the latest HTTP request contains a header with the name expected.

Parameters:

  • string expected - The header name that is expected in the HTTP response.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • string label = "" - Custom name for the step that will be shown in the report.

19. VerifyStatusCodeEquals (int)

Verifies that the response status code of the latest HTTP request matches expected.

Parameters:

  • int expected - The expected status code of the latest HTTP response.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • string label = "" - Custom name for the step that will be shown in the report.

20. VerifyStatusCodeEquals (HttpStatusCode)

Verifies that the response status code of the latest HTTP request matches expected.

Parameters:

  • HttpStatusCode expected - The expected status code of the latest HTTP response.
  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • string label = "" - Custom name for the step that will be shown in the report.

Example of method call:

RestTestBuilder
    .CreateTest("Localhost")
    .VerifyStatusCodeEquals(200);

21. VerifyUnauthorizedResponseContent

Verifies that the response content of the latest HTTP request is null or empty.

Parameters:

  • bool isPrerequisite = false - Marks the step as 'Blocked' instead of 'Failed' when it fails.
  • string label = "" - Custom name for the step that will be shown in the report.

Copyright © 2025. All rights reserved.