Sorry, we didn't find any relevant articles for you.

Send us your queries using the form below and we will get back to you with a solution.

String Generators - Compare, Evaluate, Combine, or Alter String Values Print

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:

Generator Description Examples
CompareStringGen Returns 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

 
ConcatGen Combines 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,

 

ConcatBoolenGen Allows 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

 
ConcatNumberGen Allows 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

     
ConcatParentChildGen Allows 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


 

ConstantGen Generates a constant, non-changing value.

Examples:

  • country = USA
  • currency = USD
  • tax rate = 0.07
  • branch id = 2005
  • active = true
  • status = pending
  • null
  • test
  • exclude

     
EncyrptGen Encrypts 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

FillerGen Generates a repeating value as a filler.

Examples:

  • #{BLANK}
  • #{EMPTY)
  • null
MatchStringEvalCaseGen

Checks 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

 

MatchStringGen Checks 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
NumberToWordsGen Converts a constant or referenced number value to words. 2 = Two
52 = Fifty-two

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

 
RandomStringGen Generates 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

 
RandomLetterGen Generates 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

     
RangeConstantGen Creates 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

     
RegularExpressionGen

Produces 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

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

 
StringEscapeGen Escapes 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\" 

 
StringUnEscapeGen Unescapes 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"

 
StringIndexOfGen Returns 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

 
StringLengthGen Returns 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
StringRegexGen Generates data that matches with Regex. regex = [a-z][A-Z][1-6][*]
output = kX4*, eB3*, 2D4*, qY3*

 
StringRemoveGen Removes 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
StringReplacementGen Returns 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

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

 
StringSplitIndexGen Splits 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

     
StringTypeEvalCaseGen

Check 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 caseFalse = 'false', the returned values would be:

  • false
  • false
  • true

 

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

StringTypeGen Check 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.
SubstringGen Returns a substring of characters within a larger string of characters. 

 

Here are a few examples:

  • Return the last four digits of a phone number.
     
  • Return the last four digits of an SSN.
  • Remove a prefix from a value (e.g., ID-67843, TRK-78234).
  • Use a portion of a product name, code, or label.
  • Return the date portion from a timestamp.
  • Isolate a department code from an Employee ID.