Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

String Operations Using Data Bank and Test Suite and Env. Variable Val

Options
LegacyForum
LegacyForum Posts: 1,664 ✭✭
edited December 2016 in SOAtest
Hello Everyone,

Below is an example of a Python script that extracts values from various sources (data bank, test suite variable, and environment variable) for use with string operations such as concatenation using the '+' operator...

CODE
from soaptest.api import *
from com.parasoft.api import *

# Gets a value from a data bank (line 10) or test suite variable (line 11),
# appends an environment variable value to the front of that value,
# and returns the modified value. Be sure to comment out line 11
# when using line 10 and vice versa.

def getModifiedString(context):
#value = context.getValue("Generated Data Source", "columnName")
value = context.getValue("testSuiteVariableName")

environmentVariableValue = context.getEnvironmentVariableValue("environmentVariableName")

modifiedString = environmentVariableValue + value

return modifiedString


This example is for a fairly specific use case but nonetheless uses some common methods from the SOAtest extensibility API.

Enjoy!

Regards,
Adam
Tagged: