Results and Reporting
Use these commands and functions to customize the results created by SenseTalk scripts in Eggplant Functional. (Also see The ScriptLogging in Global Properties.)
Assert
Command
Behavior: When you run an assert
command, Eggplant Functional evaluates the specified condition (an expression) as true or false. If it is evaluated as false then by default assert
throws an exception. It can also log a success, failure, or warning, depending on how the behavior is set. The failure behavior for the assert
command can be set in-line using the Assert
command properties as shown in the syntax and examples below. This behavior can also be set using The AssertionBehavior
Global Property. To improve readability, you can insert the word that
into an assert
command.
Parameters: A condition (expression) you want Eggplant Functional to evaluate.
Syntax:
assert {that} condition {with [warning | error | exception | pause]}
Example: Using The AssertionBehavior
Global Property to set the behavior of the assert
command upon evaluating the condition to be false.
set the AssertionBehavior to "warning" // Changes the default behavior of assertions to generate a warning instead of an exception
assert that x < 10 // Logs a warning message if the value of x is not less than 10 due to the AssertionBehavior global property set previously
Example:
assert that ConfirmationNumber is "128901823" with Exception "Validating the order confirmation number." // Customizes the assertion message
Example:
params Platform, Version, DebuggingMode
assert paramCount() is greater than 2 with error // Asserts that at least 3 parameter values were passed into the script, and if not, logs an error
Log the assertionErrorCount&&"assertions have failed." // Logs the total number of assertion errors that have occurred during the execution
Example:
Assert that ["iOS","Android","Windows","MacOS"] contains SUTPlatform // Asserts that the value stored in SUTPlatform is one of 4 acceptable values and if not, throws an exception to stop the execution.
Example:
put ReadText("ResultsUpperLeft","ResultsLowerRight") into UnfilteredResults // Uses OCR to read a number from the SUT and stores it in variable UnfilteredResults
Tap "Filter" // Performs an action on the SUT that causes a filter to be turned onWaitFor 10, "FilterOn"
put ReadText("ResultsUpperLeft","ResultsLowerRight") into FilteredResults
assert FilteredResults is less than UnfilteredResults with Warning // Asserts that the number read by OCR after applying a filter on the SUT is smaller than before applying the filter