What are String Generators? 

String Generators can be used to compare, evaluate, combine, or manipulate strings (replace characters, change cases, remove extra spaces, etc.). 


Please note that you can use Linked Generators to generate data to meet complex testing needs by using the Generators below with others. 


Available String Generators

The following generators can be used when working with strings:


GeneratorDescriptionExamples
CompareStringGenReturns whether two string values are equal or not.

It can compare two constant values or reference Attributes that generate the string values. 
Two referenced Attributes generate the following stings for three records:

Attribute 1 - Apple, Carrot, Tomato
Attribute 2 - Apple, Broccoli, Tomato

Generated values - true, false, true


ConcatGenCombines two or more values and returns a single-string result. Example 1 - Concatenate 'Hello' and first name generated by another Attribute or Generator along with a comma.

The result would be:
  • Hello Jim,
  • Hello Sarah,
  • Hello Tony,


ConcatBoolenGenAllows the concatenation of elements based on a Boolean reset value, separated by a delimiter, to generate accumulated data.
Example data set = red, yellow, green, blue
reset = true, false, false, true, true
delimiter = | (pipe)

Output
true = red
false = yellow
false = yellow|green
true = blue
true = red


ConcatNumberGenAllows the concatenation of elements based on a resetNumber value, separated by a delimiter, to generate accumulated data. Example data set = 1, 2, 3, 4, 5
Reset Value = 5
Delimiter = | (pipe)

Output values:
  • 1
  • 1|2
  • 1|2|3
  • 1|2|3|4
  • 1|2|3|4|5
  • starts over at 1 and repeats the same as above

ConcatParentChildGenAllows the concatenation of parent/child elements, separated by a delimiter, to generate an accumulated hierarchical directory or ancestral structure. A child is added to the hierarchy each iteration, while a parent is only added to the hierarchy when the parent value changes. The result is a concatenation that resembles a hierarchical directory or ancestral structure.
 
Below is an example where the parent changes in the following sequence: 1/1, 1/4, 6/2, and 8/1. 

The child starts at 2 and continually increases by 1.
  • 1 - 1|2
  • 2 - 1|2|3
  • 2 - 1|2|4
  • 2 - 1|2|5
  • 2 - 1|2|6
  • 6 - 1|2|6|7
  • 6 - 1|2|6|8
  • 8 - 1|2|6|8|9

ConstantGenGenerates a constant, non-changing value.Examples:
  • null
  • test
  • exclude

EncyrptGenEncrypts a string using various encryption algorithms. Value can be constant or referenced. Example: Reference the id Attribute for a test Domain.
  • testToEncrypt = #{Test.id}
  • algorithm = SHA-256
  • upperCase = true

Output for id '1' = 6B86B273FF34FCE19D6B804EFF5A3F574
7ADA4EAA22F1D49C01E52DDB7875B4B 
FillerGenGenerates a repeating value as a filler. Examples:
  • #{BLANK}
  • #{EMPTY)
  • null
MatchStringEvalCaseGenChecks a list of values for a match to a compared value. The list of values may be a set of Constants, Attribute references, or a combination of both. The match types are:
  • contains - anywhere within the string
  • startWith - at the beginning of the string
  • endsWith - at the end of the string


The match conditions are:

  • and - all must be true
  • or - only one must be true 
If compare value = 'table'
and matchType = 'contains'
and matchCase = 'true'
and the list of values =
  • Table
  • Playable
  • Stable


then matchCondition:

  • and returns False
  • or returns True 


MatchStringGenChecks a string for a value match using the contains, startWith, or endsWith matching functions.An Attribute is generating a string that contains 1 letter as the starting character and then random numbers.
  • H23864
  • J37961
  • C09143
  • N38410

If the string starts with 'C' it should return 'true', otherwise 'false'

Generated data values for four strings above:
  • false, false, true, false
NumberToWordsGenConverts a constant or referenced number value to words.2 = Two
52 = Fifty-two

PadGenPads a value either to ist left or right. Example 1 - 000red
Example 2 - red000
Example 3 - 000red000


RandomStringGenGenerates a random string based on lengths passed.

You can define the length of the string, select specific string types, include only specific characters, or exclude specific characters.

letters only - eUyrTSg
numbers only - 89645231
letters and numbers - c85YT9q1
special characters - *#&&@!
ASCII characters - x'3f6!7dwP

RandomLetterGenGenerates between 1 and 100 random letters and returns them as one string. Letters can be all lowercase, all uppercase, or mixed. Examples with 10 letters:
  • upper case -IASPRZWFAG
  • lower case - pauxbzwyin
  • mixed - iMYnDIjGdg

RangeConstantGenCreates an increasing value similar to the RangeGen; however, you are able to add a prefix and/or suffix to each generated number. Example 1
  • Range = 1 to 5
  • Prefix = test
  • Output = test1, test2, test3, test4, test5


Example 2 

  • Range = 1 to 5
  • Suffix = test
  • Output = 1test, 2test, 3test, 4test, 5test

RegularExpressionGenProduces a result by evaluating a regular expression using a constant or referenced value. Examples of regular expressions include: 
  • [a-z]
  • 1
  • a
  • $ (two or more)

If 'true' returned, then passCase provided; otherwize, failCase provided. These can be a constant or referenced value.

Example Values: 123, happy, TOO
regularExpression = [a-z] (lowercase)
passCase = true
failCase = false

Output values: false, true, false

StringCaseGenChanges the case of a generated value to CapitalCase, UpperCase, or LowerCase.CapitalCase - Apple
UpperCase - APPLE
LowerCase - apple

StringEscapeGenEscapes strings written in CSV, Java, JavaScript, HTML, XML, JSON, and SQL.

You can enter a constant string value or reference another Attribute or Linked Generator. 
Example String - "hello"

escapeJava = \"hello\"
escapeCSV = """hello"""
escapeHTML3 = "hello"
escapeXML10 = "hello"
escapeJSON = \"hello\" 

StringUnEscapeGenUnescapes strings written in Java, JavaScript, HTML, XML, JSON, and SQL.

You can enter a constant string or reference another Attribute or Linked Generator. 


escapeJava - \"hello\" becomes "hello"
escapeCSV - """hello""" becomes "hello"
escapeHTML3 - "hello" becomes "hello"

StringIndexOfGenReturns the index of a specified character or substring in a particular string. Example values = *red, yel*low, green*, blue
value = *
Output = 0, 3, 5, -1 and repeats

StringLengthGenReturns the length of the referenced string. It can be a constant or referenced value.

You can also exclude a value such as 'null', and the returned count will be '0' each time that value is encountered in the referenced values.

teleport = 8
178rt4Uko23 = 11
date = 4
StringRegexGenGenerates data that matches with Regex.regex = [a-z][A-Z][1-6][*]
output = kX4*, eB3*, 2D4*, qY3*

StringRemoveGenRemoves a token value from a referenced value. You can remove all occurrences, the first occurrence only or the last occurrence only. This can be for a constant or referenced value. 

Example - /Engine/
If remove all occurrences of '/',
then generated value would be = Engine
StringReplacementGenReturns a string replacing all the sequence of characters matching regex and replacement string.

You can enter a constant value or reference an Attribute or linked Generator.
Example 1 - For every occurrence of 'user' in a referenced Attribute value, replace it with 'name'.

Example 2 - Remove extra spaces in generated values. Reference the Attribute and use \s in the fromText parameter.
  • (800) 899-1111 becomes (800)899-1111
  • ap ple becomes apple

StringReverseGenReverses a string that the user inputs. Example - Blue
Becomes - eulB


StringSplitIndexGenSplits a constant or referenced string value by delimiter, which in turn creates an internal list. The elements in the list can then be accessed with the help of a list index. Example Strings
  • I like apples
  • I would rather have oranges
  • What do you prefer


Generated value with index set to '1'

  • like
  • would
  • do


Generated value with index set to '3' and ignoreBound 'true'

  • empty string (no value to return)
  • have
  • prefer

StringTypeEvalCaseGenCheck what type of content the string contains. You can enter a constant value or reference another Attribute.

If the result of the evaluation is true, then the value of castTrue will be returned for the record. Otherwise, the value of caseFalse will be returned. Both parameters can have a constant value or reference another Attribute.

You can perform the following checks:
  • isAlphaNumeric
  • isAllWhiteSpaces
  • isBigDecimal
  • isBigInteger
  • isDouble
  • isEmpty
  • isFloat
  • isInteger
  • isLong
  • isNumber

Example Strings:
  • I like apples
  • null
  • 1234567


If I check for isNumeric with caseTrue = 'true' and caseFales = 'false', the returned values would be: 

  • false
  • false
  • true


Alternatively, caseTrue could reference another Attribute when 'true' rather than be a constant value. 

StringTypeGenCheck what type of content the string contains.

Note: This generator works just like the StringTypeEvalCaseGen above; however, you cannot specify the evaluation value for when the case is true or false. It only returns 'true' or 'false'. 


See the example above for StringTypeEvalCaseGen.
SubstringGenReturns a substring of characters within a larger string of characters. 

To see an article example, click here.