Built in Functions
Built in Functions
The purpose of this course is to demonstrate how Automation's built-in functions can enhance
your test cases.
We want to make your University of Provar experience as accessible as possible. Please note
that you can navigate directly to lesson content and skip sidebar navigation if you are tabbing
through our course with a screen reader. You can also use these keyboard shortcuts for
alternative navigation.
NOTE: Provar Automation Advanced courses are best completed in conjunction with the use
of our Automation product. Please contact [email protected] to learn more about
becoming a customer.
Getting Started
Essential Functions
Date Functions
Number
String Manipulation
TestCase
Additional Functions
Course Resource
WR AP UP
Quiz
Course Transcript
Getting Started
This course should take about 30 minutes, and you will earn an Advanced Built-In Functions
badge upon completion.
Lesson 2 of 12
Essential Functions
In the Provar Automation Essentials certification, we covered several basic functions. Take a
moment to review them here before we move on to advanced functions.
This generates a unique value. For
example, {UniqueId(8)} will create
UniqueId
a unique ID with 8 alphanumeric
characters.
All of Automation's built-in functions are easily accessed with Content Assist, which you can open by
pressing Ctrl+space. When you select and click on a function in the list, the details for it are displayed.
Lesson 3 of 12
Date Functions
DateFormat
Use the DateFormat function when you have date fields that require specific formatting.
DateFormat Syntax
DateFormat(date,output format,timezone)
You can combine it with TODAY and DateAdd functions to make it more dynamic. Let's see what
this looks like in some examples.
With TODAY
–
The TODAY function returns the current date in the default format YYYY-MM-dd.
Let's say you want to convert it to dd/MM/YYYY.
With DateAdd
–
DateFormat also works with DateAdd. Perhaps you want to specify a date that will always be two days in
the future.
CO N T IN U E
DateParse
Use DateParse when you need to convert a string to a date. This is helpful when you want to fetch
the date from the UI of a web application and verify the selected date with the user input. A
problem will arise when the UI fetched date is in string format and the input date is in date format.
The DateParse function can convert it from string to date format.
DateParse Syntax
DateParse(DateString,InputFormat,OutputFormat)
Let's look at this in an example. We can convert a date string (15-07-2023 with format dd-MM-
yyyy) to a date with format (yyyy-MM-dd). In the function, it would read as the following:
{DateParse("15-07-2023", "dd-MM-yyyy","yyyy-MM-dd")}
Number
NumberFormat
NumberFormat function formats a number in a defined pattern. The NumberFormat class is used
to format numbers according to a specific location. Different countries have different standards
for how they format numbers.
NumberFormat Syntax
NumberFormat(numberToformat,outputFormat,language,countryCode,decimalSeparator,
groupingSeparator)
Without a decimal
–
If there is no decimal in the number then the output will format as an integer. In this example, the output
would be 123,54847.
CO N T IN U E
Round
This function rounds a number to a defined specification. For example, you may want to round the
input decimal to the closest integer.
Round Syntax
Round(number,decimal places,rounding mode)
Look at the example below. With the Round function, you could round the input number of 2.4 to 2.
The Round function gives you several options for your mode: ceiling, down, floor, half down, half
even, half up, and up. Let's look at a few of these examples.
DOWN
–
To Round using DOWN, you could set {Round(3.999,2,DOWN)} as the input and expect 3.99 as the output.
UP
–
To Round using UP, you could set {Round(3.999,2,UP)} as your input and expect 4.00 as your output.
FLOOR
–
To Round using FLOOR, you could set {Round(3.999,1,FLOOR)} as your input and expect 3.9 as your output.
Lesson 5 of 12
String Manipulation
StringNormalize
The StringNormalize function normalizes a supplied string eg. removing any leading or trailing
whitespace.
StringNormalize Syntax
StringNormalize('')
Let's look at this one in context. If you want to remove the beginning and ending extra spaces from
StringReplace
StringReplace is used when you need to modify a body of text.
StringReplace Syntax
Check out the examples below to see how this function can be used in your test cases.
Example 1
Input
–
In this example, you can see that we are replacing one string with another.
Output
–
This leads to this output.
Example 2
Input
–
In this example, you can see that are replacing a string with another function.
Output
–
This leads to this output.
CO N T IN U E
StringTrim
StringTrim removes the whitespace from a string.
StringTrim Syntax
StringTrim("")
Below you'll find some examples for using StringTrim in your test cases.
Default
–
By default, the StringTrim function will trim both ends of the string. Check out the example with "Testing."
LEADING
–
LEADING removes the white space just at the beginning of the string.
TRAILING
–
TRAILING removes the white space from the end of the string.
Lesson 6 of 12
TestCase
TestCase Functions
TestCase functions are helpful for reporting purposes, particularly to other systems. You'll see
that the syntax for each follows a pattern to make it easier for you to use.
Note that if a TestCase function is called in a callable test case and the callable test case is
called or use in the main test case, then the results will show the main test case.
TestCaseName
The TestCaseName function returns the current test case name.
TestCaseName Syntax
TestCaseName()
Input
–
Output
–
CO N T IN U E
TestCaseOutcome
TestCaseOutCome function returns the outcome of the test case. The outcome depends on the
steps executed before the function calling step. This returns Successful if the test case is
passing and Failed if the test case is failing.
TestCaseOutcome Syntax
TestCaseOutcome()
Input
–
Output Successful
–
Outcome Failure
–
CO N T IN U E
TestCasePath
TestCasePath function returns the path of the test case.
TestCasePath Syntax
TestCasePath()
Input
–
Output
–
CO N T IN U E
TestCaseSuccessful
TestCaseSuccessful function returns if the test case is successful or not. It will return the
boolean value as True if the test case is passing and False if the test case is failing.
Input
–
Output Successful
–
Output Failure
–
CO N T IN U E
TestRunErrors
TestRunErrors function returns all of the errors that occurred during the test run. This is useful
during batch execution. You can use this function at the beginning or at the end of a test case, but
it is a recommended practice that you leverage this function at the end of a test case.
TestRunErrors Syntax
TestRunErrors()
Input
–
Output
–
CO N T IN U E
TestCaseErrors
TestCaseErrors function returns the list which contains all of the errors that came before running
this function.
TestCaseErrors Syntax
TestCaseErrors()
Input
–
Output
–
Lesson 7 of 12
Additional Functions
Count
The Count function counts the number of items in a list. This is useful when checking the number
of values returned from a test step. For example, if you want to count the number of leads, the
Count function can do just that.
You can also set it for conditions to return as True or False based on the result of the test step.
Check out the syntax and a couple of use cases for the function below.
Count Syntax
Count(List)
Count Results
Consider a scenario where you have used a SOQL query and you want to count the number of results
returned from it. Your test step parameters might look similar to the image to the right.
Now let's count the lead rows returned from the SOQL query. To do so, enter the value information with the
Count function and the LeadRows variable.
Create a Condition
In this scenario, we want to use the Count function as a condition. Take a look at the example
below. The condition is set so that if more than five lead rows are counted, then the step will
delete an existing record or create a new record based on the requirement.
CO N T IN U E
Not
The Not function negates a condition. This is used when you want to make sure something
returns as not true. You can use it with loops or conditional statements, and the result will be a
boolean value.
Not Syntax
Not()
Return as True
–
Return as False
–
CO N T IN U E
IsSorted
The IsSorted function tests whether a supplied list of values is sorted in ascending or descending
order.
IsSorted Syntax
IsSorted(Values,“Name/ColNumber”,“Order”,“Type”,“Format”)
Here you can see that the results will return TRUE if the list is in descending order. It will return FALSE if not.
CO N T IN U E
GetEnvironmentVariable
The GetEnvironmentVariable(NameOfVariable) function returns the System and UserDefined
environment variable. With this function, users can know the exact path of their system variables.
This is particularly helpful with CI/CD practices.
GetEnvironmentVariable
GetEnvironmentVariable(NameOfVariable)
In this scenario, the test step would return the JAVA HOME variable, which is set in the system environment
variable.
CO N T IN U E
GetSelectedEnvironment
The GetSelectedEnvironment function returns the selected environment. This helps when you
want to run the same test case in different environments and want to know the environment
where the execution happened.
GetSelectedEnvironment Syntax
GetSelectedEnvironment()
In this example, the function will return QA as the same environment as the selected one.
Lesson 8 of 12
Course Resource
Quiz
Question
01/05
What are the benefits of using functions in your test cases? Select all that apply.
Accelerate development
02/05
DateFormat
DateParse
NumberFormat
Round
Question
03/05
Which function would you use if you wanted to your test step to return an integer instead of
NumberFormat
DateParse
Round
StringNormalize
Question
04/05
TestCaseName
TestCaseOutcome
TestCasePath
TestCaseSuccessful
Question
05/05
True or False: The Not function can be used with loops or conditional statements and return
a boolean value.
True
False
Lesson 10 of 12
You've also earned a Advanced Built-In Functions badge. You can view your badge under “My Badges”
on UP.
Lesson 11 of 12
Course Transcript
Email*
Country
Please Select