Control APIs

Introduction

This page describes Provar’s Control APIs and how each of them can be used.

Use the following links to navigate to the relevant section:

Assert API

This API compares the supplied values, failing the test if unsuccessful.  

Drag an Assert API from the API palette into your Test Case:

Update the parameters as follows:

  • Expected Value: The value that is expected
  • Actual Value: The actual value
  • Operator: See comparison type for the supported comparison types (EqualTo, LessThan, etc.)
  • Failure Message: The message that should be logged if the comparison fails
  • Case Sensitive: Whether the comparison should be case-sensitive or not.  If false then ‘abc = ABC’ will assert successfully
  • Keep trailing zeros: Whether the comparison keeps trailing zeroes when comparing numbers. By default trailing zeroes are trimmed, e.g. ‘1.0’ becomes ‘1’
  • Nulls are Greater: Whether unpopulated (or null) values should be treated as greater than non-null values.  If true then ‘a < null’ will assert successfully
  • Match Multi-line: The Multiline flag for Regular Expressions
  • Match dot all: The DotAll flag for Regular Expressions

Examples:

Actual Value Comparison Expected Value Relevant Checkbox Result
25 Greater Than 24 True – Success
1 Equals 1.0 Keep trailing zeros = false True – Success
Abcd Contains abc True – Success
ABCD Equals Case Sensitive = false True – Success
Abcd Matches bc True – Success

Then save the Test Case.

Break API

Exits the enclosing loop (For Each, While) or Switch.

Drag a Break API from the API palette into your test case:

 Then save the Test Case.  No parameters are required in this API.

Fail Test API

While all test assertions should pass in order for a test module to pass, in some situations it is desirable to temporarily allow particular tests to fail.  This API fails the Test Case with a defined message.

Drag a Fail Test API from the API palette into your Test Case:

Update the following parameter:

  • Failure Message: The message which should be displayed on Test Case failure

Then save the Test Case.

Finally API

This API creates a grouping of Test Steps that are always executed, even if prior Test Steps have failed. It can be used to run reporting steps, such as updating the test result into a spreadsheet.

Drag a Finally API from the API palette into your Test Case:

Update the following parameter:

  • Description: The label for the grouping of Test Steps. This is visible in the test

Then save the Test Case.

For Each API

For Loops provide an easy way to traverse arrays. As part of the loop, a variable is created that is incremented after each loop is completed. This variable can be used as the index to an array as well.

However, if the loop is just making a modification to each item then this method is not the most elegant solution. The For Each API in Provar simplifies this by exposing each item without needing to know its position in the list.

Drag the For Each API from the API palette into your Test Case:

Update the following parameters:

  • List: The item collection list, e.g. {1,2,3,4,5}
  • From Item: A particular value from the collection, e.g. 1
  • Value Name: The value for which need to iterate, e.g. value
  • Continue On Failure: Tick this checkbox if the for-each should continue after failure of any iteration within the loop

Then save the Test Case.

Group Steps API

This API creates a labelled grouping for a number of Test Steps within your Test Case. It can be used to make Test Cases more readable.

Drag a Group Steps API from the API palette into your Test Case:

Update the following parameter:

  • Description: The label for the grouping of Test Steps. This is visible in the test

Then save the Test Case.

If API

This API evaluates a boolean condition to determine which sub-steps will be executed. A different set of sub-steps can be defined for either result.

This API is most useful for when you need to execute certain steps based on the value of a variable which is set dynamically during the test run. The variable is checked against the expected value, which returns either TRUE or FALSE as output.

Drag an If API from the API palette into your Test Case:

Update the following parameters:

  • Condition: The IF condition to be evaluated, resulting in an output of TRUE or FALSE
  • Then: This is a grouping of sub-steps which should be executed only when the IF Condition evaluates to TRUE. This grouping is required and is added automatically under the IF step
  • Else: This is an optional grouping of sub-steps which should be executed only when the IF Condition evaluates to FALSE. See below for how to add this clause

To add an Else condition to the If statement, click the Add Clause () icon at the top of the Test Case:

Then save the Test Case.

Set Values API

This API sets the value of one or more test variables, which can then be used in Test Steps.

Drag a Set Values API from the API palette into your Test Case:

Update the following parameters:

  • Value Name: The name of the value to set. This can contain sub-values, e.g. ‘Value1.SubValue1’
  • Value: The actual value to be set
  • Value Scope: The scope to which the value applies

Then save the Test Case.

Sleep API

The Sleep API suspends test execution for the given number of seconds. The argument can be a floating point number to indicate a more precise sleep time in seconds.

Drag a Sleep API from the API palette into your Test Case:

Update the following parameter:

  • Sleep For (seconds): The number of seconds that the sleep time should last

Then save the Test Case.

Switch API

A Switch statement is used to select one of several alternatives based on the value of an integer, a character, or a string variable. Once a match is found, all subsequent statements are executed until the end of the Switch block is reached or you break out of the block.

Drag a Switch API from the API palette into your Test Case:

Update the following parameter:

  • Value: The value to switch on case

Then save the Test Case.

Wait For

This API is used to wait for a certain condition to occur before proceeding further in the test. You can also define the maximum number of attempts to be made.

Drag a Wait For API from the API palette into your Test Case:

Update the following parameters:

  • Condition: The condition to be reached for the test to continue. You can define this using the inbuilt editors
  • Test First: Tick this checkbox to test the condition first
  • Max Attempts: The maximum number of attempts to be made
  • Sleep For (seconds): The time in seconds that the sleep time should last
  • Continue on failure: Tick this checkbox if the wait-for should continue after failure

Then save the Test Case.

While API

This API executes the contained Test Steps repeatedly until the specified condition is TRUE or until a break is encountered.

Drag a While API from the API palette into your Test Case:

Update the following parameters:

  • Condition: The condition to be reached for the test to continue. You can define this using the inbuilt editors
  • Counter Name: The name of the loop counter
  • Start Value: The starting value of the counter
  • End Value: The end value of the counter. Looping will automatically end when this value is passed. If the value is less than the Start Value, then the counter will decrease with each execution instead of increasing
  • Continue on failure: Tick this checkbox if the test should continue after failure

Then save the Test Case.

2017-10-25T17:00:54+00:00

Leave A Comment