18. Appendix 1b: Vitaq Library Methods - Python

This is a list of all of the Vitaq library methods that can be used in the Test Action Scripts

18.1. add_distribution

Add a weighted distribution to a range of values.

A distribution is a range of values followed by a weight. The probability of a value being selected is proportional to the weight of its distribution range divided by the sum of all weights.

So for example if we defined a Activity Variable in Vitaq Test Automation as:

_images/20_Variable1.png

Now let’s add a distribution to ensure 90% of the time it is between 30 and 50 and 10% of the time it is between 50 and 100.

This would be done as follows:

self.variable.Expense_value.add_distribution(30, 50, 90)

self.variables.Expense_value.add_distribution(50, 100, 10)

Note: since weights are relative the following code would have exactly the same effect

self.variable.Expense_value.add_distribution(30, 50, 9000) self.variables.Expense_value.add_distribution(50, 100, 1000)

So now the probability of Expense_value being in the range of 30 to 50 is and the probability of Expense_value being in the range 50 to 100 is

As we have only added distributions for the two specific ranges then x will only be within these ranges. If we wish to allow other values then they must be specifically allowed by assigning them a weight.

18.2. add_distribution_value

Add a weighted distribution to a single value.

Add a distribution. A distribution (add_distribution) is a range of values followed by a weight. In this case the range has a single value in it. The probability of a value being selected is proportional to the weight of its distribution range divided by the sum of all weights.

So for example if range A is given a weight of 1 and range B is given a weight of 10 then the probability of a value being selected from range B is 10 / (10 + 1) and the probability of a value being selected from range A is 1 / (10 + 1).

A value may exist in multiple ranges in which case the probability of it occurring is dependent on the weights in all of the ranges

18.3. add_dynamic_distribution

Add a dynamic weighted distribution to a range of values.

Add a dynamic distribution is just like a standard distribution (see add_distribution) except that it’s effect only lasts for 1 generation cycle.

A distribution is a range of values followed by a weight. The probability of a value being selected is proportional to the weight of it’s distribution range divided by the sum of all weights. So for example if range A is given a weight of 1 and range B is given a weight of 10 then the probability of a value being selected from range B is 10 / (10 + 1) and the probability of a value being selected from range A is 1 / (10 + 1). A value may exist in multiple ranges in which case the probability of it occurring is dependent on the weights in all of the ranges.

18.4. add_dynamic_distribution_value

Add a dynamic weighted distribution to a value.

Add a dynamic distribution is just like a standard distribution (see add_distribution) except that it’s effect only lasts for 1 generation cycle.

18.5. allow_only_range

Allow only the passed range of values into the allowable ranges for this variable.

This Vitaq library method will remove all existing static (see Static vs Dynamic ranges) constraints applied up to this point and allow only the range of values supplied.

Example of how to use this method in Vitaq Test Action Script:

# For a variable defined in the Activity Variables Tab as Speed of type integer # redefine the allowable range of values for Speed to be in the range of 30 to 50

self.variables.Speed.allow_only_range(30,50)

self.variables.Speed.gen()

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

self.variables.Speed.allow_only_range(30,50)

self.variables.Speed.allow_range(60,70)

# The only allowable values are 30 to 50 and 60 to 70 self.variables.Speed.dynamic.disallow_value(70)

# The Speed variable value 70 is not allowed for the first random generation cycle # i.e. first call of the gen() method on variable Speed self.variables.Speed.gen()

# In the following while loop, during the first loop cycle (index==0) # Speed must not be 70, but any of the other values are allowed # in subsequent cycles Speed may be any of the possible values as the dynamic # constraint is removed after the first generation cycle i.e. call of gen().

index == 0

while index <= 5

self.variables.Speed.gen()

index += 1

18.6. allow_only_value

Allow only the supplied value as an allowable value for this Vitaq Activity variable.

This Vitaq library method will remove all existing static (see Static vs Dynamic ranges) constraints applied up to this point and allow only the value supplied.

Example of how to use this method in Vitaq Test Action Script:

# For a variable defined in the Activity Variables Tab as Speed of type integer # redefine the only allowable value for Speed to 70

self.variables.Speed.allow_only_value(70)

self.variables.Speed.gen()

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

self.variables.Speed.allow_only_value(70)

self.variables.Speed.allow_value(30)

# The only allowable values are 30 and 70 self.variables.Speed.dynamic.disallow_value(70)

# The value 70 is not allowed for the first random generation cycle # i.e. first call of the gen() method self.variables.Speed.gen()

# In the following while loop, during the first loop cycle (index==0) # Speed must not be 70, but any of the other values are allowed # in subsequent cycles Speed may be any of the possible values as the dynamic # constraint is removed after the first generation cycle i.e. call of gen().

index = 0

while index <= 5:

self.variables.Speed.gen()

index += 1

18.7. allow_range

Allow a range of values as allowable values for this Vitaq Activity variable.

Allow a range of values to be included in the set of values that may be selected by the Vitaq generator.

This effect of this Vitaq library method is cumulative. Thus repeated called to allow_range() will have the effect of increasing the number of allowable values that may be selected by the generator.

By default all possible values for a given type are allowable and therefore performing allow_range() as an initial constraint will have no effect. If the desired effect is to allow only this range and thereby remove all other values then the allow_only_range() member method should be used.

Example of how to use this method in Vitaq Test Action Script:

# For a variable defined in the Activity Variables Tab as Speed with range 30 to 70 # of type integer extend the only values for Speed up to 90

self.variables.Speed.allow_range(71,90)

self.variables.Speed.gen()

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

self.variables.Speed.allow_range(30,70)

self.variables.Speed.allow_range(71,90)

# The allowable values are now 30 to 90

self.variables.Speed.dynamic.disallow_value(90)

# The value 90 is not allowed for the first random generation cycle # i.e. first call of the gen() method

self.variables.Speed.gen()

# In the following while loop, during the first loop cycle (index==0) Speed must # not be 70, but any of the other values are allowed

# in subsequent cycles Speed may be any of the possible values as the dynamic # constraint is removed after the first generation cycle i.e. call of gen().

index = 0

while index <= 5:

self.variables.Speed.gen()

index += 1

18.8. allow_value

Allow a value into the allowable ranges of values for this Vitaq Activity variable.

Allow a value to be included in the set of values that may be selected by the Vitaq generator.

This effect of this Vitaq library method is cumulative. Thus repeated called to allow_value() will have the effect of increasing the number of allowable values that may be selected by the generator.

By default all possible values for a given type are allowable and therefore performing allow_value() as an initial constraint will have no effect. If the desired effect is to allow only this range and thereby remove all other values then the allow_only_value() member method should be used.

Example of how to use this method in Vitaq Test Action Script:

# For a variable defined in the Activity Variables Tab as Speed with range 30 to 70 # of type integer extend to allow one additional ‘outlier’ value for Speed of 90

self.variables.Speed.allow_value(90)

self.variables.Speed.gen()

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

self.variables.Speed.allow_range(30,70)

self.variables.Speed.allow_value(90)

# The allowable values are now 30 to 70 and 90

self.variables.Speed.dynamic.disallow_value(90)

# The value 90 is not allowed for the first random generation cycle # i.e. first call of the gen() method

self.variables.Speed.gen()

# In the following while loop, during the first loop cycle (index==0) # Speed must not be 90, but any of the other values are allowed

# in subsequent cycles Speed may be any of the possible values as the dynamic # constraint is removed after the first generation cycle i.e. call of gen().

index = 0

while index <= 5:

self.variables.Speed.gen()

index += 1

18.9. check

check(bool expr, ‘string message’, ‘true’)

Perform a check. A boolean expression is passed to the first parameter and an error() is generated with the passed message if the boolean expression evaluates false

If the third parameter “_continue_on_error” is true then error_continue() is called rather than error() allowing the run to continue.

self.check(test_result_1>100, "test_result_1 is not greater than 100")

The above code would output the error message if Test result 1 was less than or equal to 100.

18.10. clear_call_count

This will reset the call count back to the call limit (set by set_call_limit() either in the action properties or in your script ) during a current seed test run. Very useful if you want to dynamically control how many times Vitaq can execute an action during a run.

self.clear_call_count(False)

Clears the call count for this Test Action.

self.clear_call_count(True)

Clears the call count for this test Action and all next actions in the tree below this test action.

18.11. clear_dynamic_ranges

This will remove all dynamic constraints that have been applied to this point. This might be called prior to applying a new set of dynamic constraints.

Note: It is not necessary to clear dynamic ranges after generation (call of gen()) as this is done by the generator by default. After generation of a field has been completed all of its dynamic constraints are automatically cleared

Example of how to use this method in Vitaq Test Action Script:

self.variables.Speed.clear_dynamic_ranges()

18.12. disallow_range

Disallow a range values from the allowable ranges for this Vitaq Activity variable.

Disallow a range of values from being included in the set of values that may be selected by the Vitaq generator.

Each time the disallow_ranges() Vitaq library method is called, the disallowed range of values is removed from the set of allowable values. The effect is cumulative and reduces the list of allowable values.

Note: Disallowed ranges may overlap with previously disallowed ranges.

Example of how to use this method in Vitaq Test Action Script:

# For a variable defined in the Activity Variables Tab as Speed with range 30 to 70 # of type integer will be reduced to values for Speed of 30 to 50

self.variables.Speed.disallow_range(51,70)

self.variables.Speed.gen()

18.13. disallow_value

Disallow a value from the allowable ranges for this Vitaq Activity variable.

Disallow a particular of value from being included in the set of values that may be selected by the Vitaq generator.

Each time the disallow_value() Vitaq library method is called, the disallowed value is removed from the set of allowable values. The effect is cumulative and reduces the list of allowable values.

Note: If a value is removed using disallow_value() which is already excluded from the allowed set of values the excluded set remains unchanged.

Example of how to use this method in Vitaq Test Action Script:

# For a variable defined in the Activity Variables Tab as Speed with range 30 to 90 # of type integer will be reduced to values for Speed of 30 to 89

self.variables.Speed.disallow_value(90)

self.variables.Speed.gen()

18.14. disallow_values

Disallow a list of values from the allowable ranges for this Vitaq Activity variable.

Disallow a list of values from being included in the set of values that may be selected by the Vitaq generator.

Each time the disallow_values() Vitaq library method is called, the disallowed values are removed from the set of allowable values. The effect is cumulative and reduces the list of allowable values.

Note: If a value is removed using disallow_values() which are already excluded from the allowed set of values the excluded set remains unchanged.

Example of how to use this method in Vitaq Test Action Script:

# For a variable defined in the Activity Variables Tab as Speed with range 30 to 90 # of type integer will be reduced to values for Speed of 30 to 69 and 71 to 89.

self.variables.Speed.disallow_values(70,90)

self.variables.Speed.gen()

18.15. do_not_repeat

Set this field to not reuse values.

For example if we a Test ACtivity Variable called listOfNames, with a list of names such as Bill,Bob,Claire,Karen,Monty,Pilaty,Seamus. By default a Activity Variable generation requestData() method can select any value on each and every generation cycle. By setting do_not_repeat(), each time a value is generated then that value will be removed from the list of allowable values. This means that the same value will not be selected twice.

self.variables.listOfNames.do_not_repeat(true)

Note: After enough generation cycles have been executed then all of the available values may be exhausted. Trying to generate when there are no available values to select will cause an exception. The user should take care of resetting the constraints if this might be a problem in their Test Activity. Note: You can also turn off the do_not_repeat on a test activity variable by using:

self.variables.listOfNames.do_not_repeat(false)

Warning: This method is only valid within a given seed. As soon as you start a new Vitaq run with a new seed value, then Vitaq will clear all methods and start again from a fresh setUp.

18.16. dynamic_allow_only_list

A dynamic constraint only applies for a single call of the Vitaq generator gen() for a Test Action Script generation of this variable. Dynamically allow a user defined list of text values for this variable, removing existing allowable values. The *_list methods take a Python syntax list or dict: (Note: A dict is a Python programming term for a dictionary of text variables) A list i.e. [“dog”, “cat”, “hamster”, “rabbit”, “goldfish”] – square brackets, comma separated, strings quoted with ‘, “ or ‘’’., userlist text values may not contain a comma in the list name.

Only allow these text values to be selected by the Vitaq generator. This removes any pre-existing dynamic or static user defined lists of text values for the variable and allows only these values defined in the user list of text values. This will only apply to a single call of the generator in a Test Action Script and will be cleared after the gen() call has been completed. This Vitaq library method will constrain the Vitaq generation gen() of new values for Vitaq Activity Variables to be values of those which are a defined in the list when called in a Test Action Script.

Example of how to use this method in Vitaq Test Action Script:

# This will generate a new value for a specific Vitaq Activity Variable (in this # example Expense) which has already been defined in the Activity Variables tab

self.variables.Expense.dynamic_allow_only_userlist[lunch,dinner,drink]

self.variables.Expense.gen()

Example of how to use this method with a weight in Vitaq Test Action Script:

Weights are used to define the probability of selecting a text value in the User list. To use weights the userlist is specified with curly brackets { } and every name needs to have a colon and a value that provides weighting.

# 50% probability of selecting the text value of lunch, 20% dinner and 30% drink

self.variables.Expense.dynamic_allow_only_userlist{lunch:50,dinner:20,drink:30}

self.variables.Expense.gen()

18.17. dynamic_allow_only_userlist

A dynamic constraint only applies for a single call of the Vitaq generator gen() for a Test Action Script generation of this variable. Dynamically allow a user defined list of text variables for this variable, removing existing allowable values.

The *_userlist methods take a less formal string: (Note: A string is a programming term for a type of text variable) A comma separated list i.e. dog, cat, hamster, rabbit, goldfish – comma separated strings, userlist text values may not contain a comma in the list name.

Only allow these text values to be selected by the Vitaq generator. This removes any pre-existing dynamic or static user defined lists of text values for the variable and allows only these values defined in the user list of text values. This will only apply to a single call of the generator in a Test Action Script and will be cleared after the gen() call has been completed. This Vitaq library method will constrain the Vitaq generation gen() of new values for Vitaq Activity Variables to be values of those which are a defined in the list when called in a Test Action Script.

Example of how to use this method in Vitaq Test Action Script:

# This will generate a new value for a specific Vitaq Activity Variable (in this # example Expense) which has already been defined in the Activity Variables tab

self.variables.Expense.dynamic_allow_only_userlist[lunch,dinner,drink]

self.variables.Expense.gen()

Example of how to use this method with a weight in Vitaq Test Action Script:

Weights are used to define the probability of selecting a text value in the User list. To use weights the userlist is specified with curly brackets { } and every name needs to have a colon and a value that provides weighting.

# 80% probability of selecting the text value of Tram and 20% Bus

self.variables.Expense.dynamic_allow_only_userlist{‘Tram’:80,’Bus’:20}.gen()

18.18. dynamic_allow_list

A dynamic constraint only applies for a single call of the Vitaq generator gen() for a Test Action Script generation of this variable.

Dynamically allow list of text variables for this variable, add to anything that was there before, so there are the items of this new list, as well as the items of the previous list. A variable that was in the previous list and is not in the new list will still be available for selection.

This will only apply to a single call of the generator in a Test Action Script and will be cleared after the gen() call has been completed. This Vitaq library method will constrain the Vitaq generation gen() of new values for Vitaq Activity Variables to be values of those which are a defined in the ‘extended list’ list when called in a Test Action Script.

Example of how to use this method in Vitaq Test Action Script:

# This will add new values for a specific Vitaq Activity Variable (in this # example Expense) which has already been defined in the Activity Variables tab

self.variables.Expense.dynamic_allow_list[‘snack’,’breakfast’] self.variables.Expense.gen()

Weights are used to define the probability of selecting a text value in the User list. To use weights the userlist is specified with curly brackets { } and every name needs to have a colon and a value that provides weighting.

Example of how to use this method with a weight in Vitaq Test Action Script:

# If the list that you are ‘extending’ contains weights. When adding new items # with weights the probability of being selected gets re-calculated as weight value # divided by total of all weight values. i.e. If you had 50% probability of # selecting the text value of lunch, 20% dinner and 30% drink, then by adding two # new items to the list with a :80 and :20 weight All weight probabilities are # divided by the new total which is 200. So, 25% lunch, 10% dinner, 15% drink, # 40% snack and 10% breakfast

self.variables.Expense.dynamic_allow_list{[‘snack’:80,’breakfast’:20}

self.variables.Expense.gen()

18.19. dynamic_allow_userlist

A dynamic constraint only applies for a single call of the Vitaq generator gen() for a Test Action Script generation of this variable. Dynamically allow list of text variables for this variable, add to anything that was there before, so there are the items of this new list, as well as the items of the previous list. A variable that was in the previous list and is not in the new list will still be available for selection. The *_userlist methods take a less formal string: (Note: A string is a programming term for a type of text variable) A comma separated list i.e. dog, cat, hamster, rabbit, goldfish – comma separated strings, userlist text values may not contain a comma in the list name. This will only apply to a single call of the generator in a Test Action Script and will be cleared after the gen() call has been completed. This Vitaq library method will constrain the Vitaq generation gen() of new values for Vitaq Activity Variables to be values of those which are a defined in the ‘extended list’ list when called in a Test Action Script.

Example of how to use this method in Vitaq Test Action Script:

# This will add new values for a specific named Vitaq Activity Variable (in this # example Expense) which has already been defined in the Activity Variables tab

self.variables.Expense.dynamic_allow_userlist[snack,breakfast]

self.variables.Expense.gen()

Weights are used to define the probability of selecting a text value in the User list. To use weights the userlist is specified with curly brackets { } and every name needs to have a colon and a value that provides weighting.

Example of how to use this method with a weight in Vitaq Test Action Script:

# If the list that you are ‘extending’ contains weights. When adding new items # with weights the probability of being selected gets re-calculated as weight value # divided by total of all weight values. i.e. If you had 50% probability of # selecting the text value of lunch, 20% dinner and 30% drink, then by adding two # new items to the list with a :80 and :20 weight All weight probabilities are # divided by the new total which is 200. So, 25% lunch, 10% dinner, 15% drink, # 40% snack and 10% breakfast

self.variables.Expense.dynamic_allow_userlist{[snack:80,breakfast:20}

self.variables.Expense.gen()

18.20. dynamic_allow_only_range

Dynamically (see Static vs Dynamic ranges) allow a range of values as allowable values removing existing allowable values for this Vitaq Activity variable. Only allow this range of values to be included in the set of values that may be selected by the Vitaq generator. This removes the pre-existing dynamic and static ranges and allows only this range. This will only apply to a single generation cycle i.e. a single call of gen() and will be cleared after completion of a generation on this field.

Example of how to use this method in Vitaq Test Action Script:

# For a variable defined in the Activity Variables Tab as Speed with range 30 to 70 # of type integer change the range of values for Speed to be 71 to 90

self.variables.Speed.dynamic_allow_only_range(71,90)

self.variables.Speed.gen()

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

self.variables.Speed.allow_range(30,70)

self.variables.Speed.allow_range(71,90)

# The allowable values are now 30 to 90

self.variables.Speed.dynamic_allow_only_range(71-90)

# The values 71 to 90 are the only ones allowed for the first generation cycle # i.e. first call of the gen() method self.variables.Speed.gen() # In the following while loop, during the first loop cycle (index==0) Speed will be # between 71 to 90. # in subsequent cycles Speed may be any of the possible values as the dynamic # constraint is removed after the first generation cycle i.e. call of gen().

index = 0

while index <= 5:

self.variables.Speed.gen()

index += 1

18.21. dynamic_allow_only_value

Dynamically (see Static vs Dynamic ranges) allow a value as the only allowable value removing existing allowable values for this Vitaq Activity variable. Only allow this value to be selected by the Vitaq generator. This removes the preexisting dynamic and static ranges and allows only this range. This will only apply to a single generation cycle i.e. a single call of gen() and will be cleared after completion of a generation on this field.

Example of how to use this method in Vitaq Test Action Script:

# For a variable defined in the Activity Variables Tab as Speed with range # 30 to 70 of type integer change the values for Speed to 90

self.variables.Speed.dynamic_allow_only_value(90)

self.variables.Speed.gen()

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

self.variables.Speed.allow_range(30,70)

self.variables.Speed.allow_range(71,90)

# The allowable values are now 30 to 90

self.variables.Speed.dynamic_allow_only_value(90)

# The value 90 is the only one allowed for the first generation cycle `` ``# i.e. first call of the gen() method

self.variables.Speed.gen()

# In the following while loop, during the first loop cycle (index==0) Speed will be # between 90.

# in subsequent cycles Speed may be any of the possible values as the dynamic # constraint is removed after the first generation cycle i.e. call of gen().

index = 0

while index <= 5:

self.variables.Speed.gen()

index += 1

18.22. dynamic_allow_only_values

Dynamically (see Static vs Dynamic ranges) allow a list of values as the only allowable values removing existing dynamic and static allowable values for this Vitaq Activity variable temporarily. Only allow these values to be selected by the Vitaq generator. This removes the preexisting dynamic and static ranges and allows only these values. This will only apply to a single generation cycle i.e. a single call of gen() and will be cleared after completion of a generation on this field.

Example of how to use this method in Vitaq Test Action Script:

# For a variable defined in the Activity Variables Tab as Speed with range # 30 to 70 of type integer change the values for Speed to be 80 and 90

self.variables.Speed.dynamic_allow_only_values(80,90)

self.variables.Speed.gen()

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

self.variables.Speed.allow_range(30,70)

self.variables.Speed.allow_range(71,90)

# The allowable values are now 30 to 90

self.variables.Speed.dynamic_allow_only_values(80, 90)

# The values 80 and 90 are the only values allowed for the first generation cycle # i.e. first call of the gen() method

self.variables.Speed.gen()

# In the following while loop, during the first loop cycle (index==0) Speed will be # between either 80 or 90. # in subsequent cycles Speed may be any of the possible values as the dynamic # constraint is removed after the first generation cycle i.e. call of gen().

index = 0

while index <= 5:

self.variables.Speed.gen()

index += 1

18.23. dynamic_allow_range

Dynamically (see Static vs Dynamic ranges) allow a range of values for this Activity Variable. Allow only a range of values to be selected by the Vitaq generator.

This will only apply to a single generation cycle i.e. a single call of gen() and will be cleared after completion of a generation on this field.

Example of how to use this method in Vitaq Test Action Script:

# For a variable defined in the Activity Variables Tab as Speed with range # 30 to 70 of type integer change the values for Speed to be 80 and 90

self.variables.Speed.dynamic_allow_only_range(80,90)

self.variables.Speed.gen()

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

self.variables.Speed.allow_range(30,70)

self.variables.Speed.allow_range(71,90)

# The allowable values are now 30 to 90

self.variables.Speed.dynamic_allow_only_range(80, 90)

# The values 80 to 90 are the only values allowed for the first generation cycle # i.e. first call of the gen() method

self.variables.Speed.gen()

# In the following while loop, during the first loop cycle (index==0) Speed will # be between either 80 to 90.

# in subsequent cycles Speed may be any of the possible values as the dynamic # constraint is removed after the first generation cycle i.e. call of gen().

index = 0

while index <= 5:

self.variables.Speed.gen()

index += 1

18.24. dynamic_allow_value

Dynamically (see Static vs Dynamic ranges) allow a value into the allowable values for this Vitaq Activity variable.

Allow a value to be included in the set of values that may be selected by the Vitaq generator. This will only apply to a single generation cycle i.e. a single call of gen() and will be cleared after completion of a generation on this field.

Example of how to use this method in Vitaq Test Action Script:

# For a variable defined in the Activity Variables Tab as Speed with range # 30 to 70 of type integer change the values to include a Speed of 90

self.variables.Speed.dynamic_allow_value(90)

self.variables.Speed.gen()

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

self.variables.Speed.allow_range(30,70)

self.variables.Speed.allow_range(71,80)

# The allowable values are now 30 to 80

self.variables.Speed.dynamic_allow_value(90)

# The value 90 is allowed for the first generation cycle # i.e. first call of the gen() method

self.variables.Speed.gen()

# In the following while loop, during the first loop cycle (index==0) Speed could # be between 30 to 80 or 90.

# in subsequent cycles Speed can only be between 30 and 80 as the dynamic # constraint is removed after the first generation cycle i.e. call of gen().

index = 0

while index <= 5:

self.variables.Speed.gen()

index += 1

18.25. dynamic_allow_values

Dynamically (see Static vs Dynamic) allow a list of values into the allowable values for this Vitaq Activity variable.

Allow a list of values to be included in the set of values that may be selected by the Vitaq generator. This will only apply to a single generation cycle i.e. a single call of gen() and will be cleared after completion of a generation on this field.

Example of how to use this method in Vitaq Test Action Script:

# For a variable defined in the Activity Variables Tab as Speed with range 30 to 70 # of type integer change the values to include a Speed of 90

self.variables.Speed.dynamic_allow_values(90,100)

self.variables.Speed.gen()

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

self.variables.Speed.allow_range(30,70)

self.variables.Speed.allow_range(71,80)

# The allowable values are now 30 to 80

self.variables.Speed.dynamic_allow_values(90,100)

# The values 90 and 100 are added for the first generation cycle # i.e. first call of the gen() method

self.variables.Speed.gen()

# In the following while loop, during the first loop cycle (index==0) Speed could # be between 30 to 80 or 90 or 100.

# in subsequent cycles Speed can only be between 30 and 80 as the dynamic # constraint is removed after the first generation cycle i.e. call of gen().

index = 0

while index <= 5:

self.variables.Speed.gen()

index += 1

18.26. dynamic_disallow_list

Dynamically (see Static vs Dynamic) disallow a list of text values from being included in the set of values that may be selected by the Vitaq generator gen() This will only apply to a single generation cycle i.e. a single call of gen() and will be cleared after completion of a generation on this field. Dynamically disallow a certain list of text variables for this Activity Variable, removing from what was there before, so there are less items of this new list than the items of the previous list.

This will only apply to a single call of the generator in a Test Action Script and will be cleared after the gen() call has been completed. This Vitaq library method will constrain the Vitaq generation gen() of new values for Vitaq Activity Variables to be values of those which are a defined in the ‘reduced list’ list when called in a Test Action Script.

Example of how to use this method in Vitaq Test Action Script:

# This will remove values for a specific Vitaq Activity Variable (in this # example Expense) which has already been defined in the Activity Variables tab

self.variables.Expense.dynamic_disallow_list[‘lunch’,’dinner’]

self.variables.Expense.gen()

18.27. dynamic_disallow_userlist

The _userlist methods take a less formal string: (**Note:* A string is a programming term for a type of text variable). A comma separated list i.e. dog, cat, hamster, rabbit, goldfish. (Note: userlist text values may not contain a comma in the list name.)

Dynamically (see Static vs Dynamic) disallow a list of text values from being included in the set of values that may be selected by the Vitaq generator gen() This will only apply to a single generation cycle i.e. a single call of gen() and will be cleared after completion of a generation on this field.

Dynamically disallow a certain list of text variables for this Activity Variable, removing from what was there before, so there are less items of this new list than the items of the previous list.

This will only apply to a single call of the generator in a Test Action Script and will be cleared after the gen() call has been completed. This Vitaq library method will constrain the Vitaq generation gen() of new values for Vitaq Activity Variables to be values of those which are a defined in the ‘reduced list’ list when called in a Test Action Script.

Example of how to use this method in Vitaq Test Action Script:

# This will remove values for a specific Vitaq Activity Variable (in this # example Expense) which has already been defined in the Activity Variables tab

self.variables.Expense.dynamic_disallow_userlist[lunch,dinner]

self.variables.Expense.gen()

In this case the values in the list remove the corresponding entries in the previous list. A variable that was in the previous list and is not in the new list will still be available for selection. A variable that was in the previous list and is in the new list will be removed from selection. A value not in the previous list, but in the new list will have no effect. All of this holds for the next generation cycle of this variable only.

18.28. dynamic_disallow_range

Dynamically (see Static vs Dynamic ranges) disallow a range of values for this Activity Variable. Disallow a range of values to be selected by the Vitaq generator. This will only apply to a single generation cycle i.e. a single call of gen() and will be cleared after completion of a generation on this field.

Example of how to use this method in Vitaq Test Action Script:

# For a variable defined in the Activity Variables Tab as Speed with range 30 to 70 # of type integer change the values for Speed to be 30 to 59

self.variables.Speed.dynamic_disallow_range(60,70)

self.variables.Speed.gen()

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

self.variables.Speed.allow_range(30,70)

self.variables.Speed.allow_range(71,90)

# The allowable values are now 30 to 90

self.variables.Speed.dynamic_disallow_range(71, 90)

# The values 71 to 90 are disallowed values for the first generation cycle # i.e. first call of the gen() method

self.variables.Speed.gen()

# In the following while loop, during the first loop cycle (index==0) Speed will # be between either 30 to 70.

# in subsequent cycles Speed may be any of the possible values as the dynamic # constraint is removed after the first generation cycle i.e. call of gen().

index = 0

while index <= 5:

self.variables.Speed.gen()

index += 1

18.29. dynamic_disallow_value

Dynamically (see Static vs Dynamic ranges) disallow a value for this Activity Variable. Disallow a value to be selected by the Vitaq generator. This will only apply to a single generation cycle i.e. a single call of gen() and will be cleared after completion of a generation on this field.

Example of how to use this method in Vitaq Test Action Script:

# For a variable defined in the Activity Variables Tab as Speed with range 30 to 70 # of type integer change the values for Speed to be 30 to 59

self.variables.Speed.dynamic_disallow_value(70)

self.variables.Speed.gen()

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

self.variables.Speed.allow_range(30,70)

self.variables.Speed.allow_range(71,90)

# The allowable values are now 30 to 90

self.variables.Speed.dynamic_disallow_value(90)

# The value 90 is disallowed values for the first generation cycle # i.e. first call of the gen() method

self.variables.Speed.gen()

# In the following while loop, during the first loop cycle (index==0) Speed will # be between either 30 to 89.

# in subsequent cycles Speed may be any of the possible values as the dynamic # constraint is removed after the first generation cycle i.e. call of gen().

index = 0

while index <= 5:

self.variables.Speed.gen()

index += 1

18.30. dynamic_disallow_values

Dynamically (see Static vs Dynamic ranges) disallow a list of values for this Activity Variable. Disallow a list of value to be selected by the Vitaq generator. This will only apply to a single generation cycle i.e. a single call of gen() and will be cleared after completion of a generation on this field.

Example of how to use this method in Vitaq Test Action Script:

# For a variable defined in the Activity Variables Tab as Speed with range 30 to 70 of type integer change the values for Speed to be 30 to 59

self.variables.Speed.dynamic_disallow_values(70, 80, 90)

self.variables.Speed.gen()

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

self.variables.Speed.allow_range(30,70)

self.variables.Speed.allow_range(71,90)

# The allowable values are now 30 to 90

self.variables.Speed.dynamic_disallow_values(70,80,90)

# The values 70, 80 and 90 are disallowed values for the first generation cycle # i.e. first call of the gen() method

self.variables.Speed.gen()

# In the following while loop, during the first loop cycle (index==0) Speed will # be between either 30 to 69, 71 to 79 or 81 to 89

# in subsequent cycles Speed may be any of the possible values as the dynamic # constraint is removed after the first generation cycle i.e. call of gen().

index = 0

while index <= 5:

self.variables.Speed.gen()

index += 1

18.31. error

Reports an error to std_error and throws an exception of type std::string

error('text', subMessage = false)

Parameters: text The string to be output with the error subMessage This message will be included in a higher error message therefore do not display the prefix and ERROR strings.

Note: As error reports its output to the standard error stream, messages may appear out of sync with messages sent to the standard output stream. Normally this is not an issue but if it is desirable to ensure that all output both from standard output and standard error is displayed in exactly the order that calls are made then it may be desirable to force the standard error stream to use the same stream buffer as standard output.

18.32. error_continue

Reports an error to std_error and does not throw an exception

error_continue('text', subMessage = false)

Parameters: text The string to be output with the error subMessage This message will be included in a higher error message therefore do not display the prefix and ERROR strings.

Note: As error_continue reports its output to the standard error stream, messages may appear out of sync with messages sent to the standard output stream. Normally this is not an issue but if it is desirable to ensure that all output both from standard output and standard error is displayed in exactly the order that calls are made then it may be desirable to force the standard error stream to use the same stream buffer as standard output.

18.33. gen

This Vitaq library method will generate new values for Vitaq Activity Variables when called in a Test Action Script.

Example of how to use this method in Vitaq Test Action Script:

# This will generate a new value for all Vitaq Activity Variables defined in the # Activity Variable tab.

self.variables.gen()

# This will generate a new value for a specific named Vitaq Activity Variable # (i.e. Expense_value) which is already defined in the Activity Variable tab.

self.variables.Expense_value.gen()

18.34. get_error_count

Get the error count.

Returns the number of errors that have been issued by error() or error_continue()

Returns: the count of errors so far

See Also: error , error_continue , set_continue_on_error , reset_error_count

18.35. get_seed

Return the start seed for this Test Activity if used in the green Starting Action Test Script or for a specific Test Action if used in a specific Test Action Script.

Example of how to use this method in Vitaq Test Action Script:

print ('This Test Activity is started with seed value = ', self.get_seed())

18.36. get_value

This Vitaq library method will get the current values for Vitaq Activity Variables when called in a Test Action Script.

Example of how to use this method in Vitaq Test Action Script:

# This will get a value for a specific named Vitaq Activity Variable # (i.e. Expense_value) which is already defined in the Activity Variable tab.

self.variables.Expense_value.get_value()

18.37. get_warning_count

Get the warning count.

Returns the number of warnings that have been issued by warning()

Returns: the count of warnings so far

See Also: warning(), get_warning_count(), reset_warning_count(), get_error_count

18.38. implies

This is a special Vitaq library method for building implication constraints.

This method takes two boolean relational constraint expressions as its inputs.

The implication means that if the first expression is true then the second expression must also be true. For example:

Let’s imagine that we have 3 generatable Vitaq Activity Variables of type Integer in our Test Activity A, B, and C. The rule that we wish to specify is “if A is greater than B then C must be negative, otherwise C may be positive or negative” This might more concisely be written “A > B implies C < 0 From a constraint perspective this might break down into two separate constraints i.e. If A > B then keep(C<0); If C >= 0 then keep(A<=B); This might be simplified If LHS==true then RHS=true: If RHS==false then LHS=false:

This would then be written as a constraint in our Test Action Script as follows

Example of how to use this method in Vitaq Test Action Script:

# implies(LHS, RHS)

self.variables.implies(A>B, C<0);

Since generation order can vary then either of the above constraints may need to be applied. The implies method allows us to express this relationship by writing implies(LHS, RHS);

18.39. keep

This is a special Vitaq library method for building relational constraints.

A boolean relational constraint expression may be passed as a parameter to the keep() method to effect a generation rule constraint.

This method provides the mechanism to apply relational constraints to fields. i.e. relating two or more fields so that when generated they obey these constraint rules. The parameter passed to the keep constraints must be derived from

either: the comparison of two Vitaq Activity variables of type integer.

Example of how to use this method in Vitaq Test Action Script:

# Equality constraint. This constrains Integer_A and Integer_B to be equal

self.variables.keep (Integer_A==Integer_B)

or: the comparison of one GenField variable with a constant e.g.

Example of how to use this method in Vitaq Test Action Script:

# Greater than constraint. This constrains A to be greater than 100

self.variables.keep(IntegerA>100)

Constraint example: In the following example the equality constraint constrains field A and field B to have the same value and field B to be less than field C. Irrespective of the generation order these constraints will be obeyed.

In the example whenever the Activity Variables are generated by calling it’s gen() method, fields A, B and C will be generated such that they obey their relational constraints i.e Integer_A==Integer_B and Integer_B<Integer_C. If Integer_A, Integer_B or Integer_C are individually generated at any time i.e. by calling self.variables.Integer_A.gen() then the Vitaq generator will also maintain these constraints.

Example of how to use this method in Vitaq Test Action Script:

self.variables.Integer_A.allow_only_range(-100, 100)

self.variables.Integer_C.allow_only_range(-100, 100)

self.variables.keep(Integer_A==Integer_B);

self.variables.keep(Integer_B<Integer_C);

# Non equality constraint A must not be equal to C

self.variables.keep(Integer_A!=Integer_C)

Note: The above behaviour can lead to unexpected results since in the case of individual field generation the current values of the related fields will be used. So assuming Integer_A==5 and Integer_B==5 from a previous generation then if we issue Integer_A.gen() then Integer_A will be constrained to be 5 to meet the constraint keep(Integer_A==Integer_B). The way to ensure that both Integer_A and Integer_B are regenerated together would be to remove B from constraint resolution by setting it inactive using

self.variables.Integer_B.set_active(false)

This will cause any constraint containing B to be ignored in generation. Care must be taken using this mechanism as this may cause undesirable generation results and B should be restored active i.e.

self.variables.Integer_B.set_active(true);

# after generating A.

18.40. redirect_stderr

Redirect output to stderr to a file.

The filename supplied will be used for the output for error() and warning() messages rather than standard error output. Supplying a empty string will cause the output to go to stderr.

In order to suppress messages altogether then the output may be sent to “nul” for Windows.

self.redirect_stderr('../output/Test_GUI_003_25_0_stderr.txt')

18.41. redirect_stdout

Redirect standard output to a file.

The filename supplied will be used for the output for info() messages rather than standard output.

In order to suppress messages altogether then the output may be sent to “nul” for Windows

self.redirect_stdout('../output/Test_GUI_003_25_0_stdout.txt')

18.42. reset_distribution

Remove all current distribution ranges. All distribution ranges that have been applied so far will be removed. This includes both static and dynamic distributions applied. The result will be that all values satisfying all other currently applicable range constraints will be equally likely.

Example of how to use this method in Vitaq Test Action Script:

self.reset_distribution

18.43. reset_error_count

Reset the error count.

reset_error_count()

18.44. reset_ranges

Remove all constraints, both static and dynamic. This method will remove all of the range constraints from a field, both dynamic and static and the allowable range returns to the full allowable range for the type in use.

Example of how to use this method in Vitaq Test Action Script:

self.reset_ranges

18.45. reset_warning_count

Reset the warning count.

reset_warning_count()

18.46. set_active

Set the generation of this Activity Variable to be active (inactive) If a Vitaq Activity Variable is active then it will be used in generation. If it is inactive then it will not be generated and it will not be considered in constraints.

Example of how to use this method in Vitaq Test Action Script with an Activity Variable defined as Integer_A:

self.variables.Integer_A.set_active

18.47. set_continue_on_error

Set the continue_on_error flag, this flag controls whether a call to error() will cause the execution to stop or continue. By default this flag is false.

Parameters value When set true allows execution to continue when error() is called when set false an exception will be thrown when error() is called See Also get_continue_on_error(), error(), error_continue()

18.48. set_distribution_kind

This method is used to set the probability distribution to be applied to the Vitaq generation of variable values

The user can set a Flat distribution where every value has an equal probability of being generated or a Custom distribution where the user defines their own distribution

Example of how to use this method in Vitaq Test Action Script:

self.variables.set_distribution_kind(Custom)

Note: This is the default distribution for generating values, but you might want to reset back to Flat after setting Custom distributions

self.variables.set_distribution_kind(Flat)

18.49. set_enabled

Enables the Test Action to be called or not called and hence can control the calling of next allowable Test Actions in the connected Test Action flow. Set the Test Action to be enabled/disabled in the Test Action Script. If disabled then the Test Action will not be selected and called as a next allowable Test Action.

Example of how to use this method in Vitaq Test Action Script:

# Dynamically disable the Add_Particpant Test Action when we have used up all # of the names on the Add_Participant_Name Activity Variable list

if len(self.parent.Disallowed)==len(self.variables.Add_Participant_Name.data):

self.set_enabled(False)

18.50. set_value

Set a value manually for a self.variable.gen().

Set the current value for this generation field. This can be used instead of gen to set the field to a specific value. Any dynamic constraints will be cleared after execution. set_value() may set the field to a value outside of that constrained by the constraints without giving an error. This is at the users discretion.

Example of how to use this method in Vitaq Test Action Script for setting the value of Activity Variable called Speed of type integer:

self.variables.Speed.set_value(55)