You can use assertion statements to determine that your script is receiving the expected results. You use the session status to determine session status whether your jobs have failed because of an uncaught exception or an assertion statement failed.
In the following sections, you'll find an assertion example and learn how to use the session status to determine which scripts have issues.
Use Assertions to Verify Expected Results
Assert statements use a simple syntax to verify an expected result. You can also provide a message to display if the assertion fails. In the example below, the message "Title should contain AppDynamics" will be displayed if the assertion fails.
You can also verify that a string is not in the result or the truth of a mathematical expression. Assert statements that are false will result in a session status of
Use the Session Status to Find Script Issues
The two-session statuses
FAILED indicate that the script had an issue. If the session status is
BROKEN, it means that your script threw an uncaught exception. You'll most likely need to review your code and look for errors. See Exceptions for a list of common exceptions.
If the session state is
FAILED, an assert statement failed or if you checked "Fail on page load error" and the page failed to load. You'll need to determine why your assertion statement failed or why the page couldn't be loaded.
You can view the results of assertion statements in the session status detail and script output. From the Session Details page, you can view failed assert statements in a red exception box at the top and from the Waterfall tab:
Failed assert statements will also appear in the Script Output dialog: