Skip to main content

Modularity

TesmonLang is designed to enable modularization and reuse across files. With native support for this feature, Tesmon users can create modular components that can be easily shared and used in multiple tests or other elements, which can improve code reusability and reduce duplication. This feature can make it easier to maintain and update tests over time and improve the overall organization and efficiency of testing efforts.

Here are two examples of how to use modularization and reuse in Tesmon:

Example 1

This example demonstrates how to reference a variable from another file. When the test is executed, the value of baseUrl will be http://localhost:5000

variables.yml
variables:
appHost: localhost
tests.yml
actions:
register:
type: HTTP::CLIENT
props:
method: POST
baseUrl: http://${{variables.appHost}}:5000
path: "/user"
headers:
"Content-Type": "application/x-www-form-urlencoded"
body: |
username=user1&password=pass1

Example 2

This example will show how to use the taskAction register in another file.

actions.yml
actions:
register:
props: ...
tests.yml
tasks:
- id: t1
action: actions.register