Scripts
TesmonLang features a powerful runtime based on Python that allows for dynamic behavior in your tests. With this functionality, you can create tests that include dynamic parameters, data passing between tasks, and more.
A script is a test execution element that uses Python's runtime to provide custom dynamic behavior to a test. You can add a script to the following phases of a task:
- beforeScript: Executes before the task action.
- validate: Executes after the task action. Use this phase to validate the task result.
- afterScript: Executes after the task action. Use this phase to set the context for the rest of the test.
Supported Language: Python
Current Version: 3.11
Syntax of a Script
import uuid
print("Generated UUID: " + str(uuid.uuid4()))
Examples
📄️ Inline Script
TesmonLang allows you to include scripts directly within your tests, which can be useful for adding dynamic behavior. This is known as an inline script, and it can be useful for quickly implementing simple or one-off functionality without having to create a separate script file. Inline scripts can make it easier to add custom behavior to your tests and to adapt them to changing requirements or conditions.
📄️ .py Files
TesmonLang allows you to import and use custom Python scripts in your tests. This can be useful for adding more complex dynamic behavior or functionality.
📄️ Python Packages
TesmonLang allows you to install and use Python packages in your tests. This can be useful for leveraging existing Python libraries or adding additional functionality to your tests that are unavailable natively in the TesmonLang.
📄️ Examples
beforeScript