Skip to main content

TesmonLang

Tesmon harnesses the power of its custom language, TesmonLang, to facilitate test authoring. Built upon the foundations of YAML and Python, TesmonLang strikes a perfect balance between simplicity and power. This language empowers users to define tests with ease while offering the flexibility to incorporate dynamic behaviors through Python scripts.

With TesmonLang, you can seamlessly express your test scenarios using familiar YAML syntax while leveraging the robust capabilities of Python for advanced customization. This unique combination enables you to create tests that are both straightforward to write and capable of handling complex testing scenarios.

Test

A test in TesmonLang is the fundamental functional element and consists of a list of defined tasks executed sequentially. A test requires at least one task and can have multiple tasks.

drawing

Example code

tests:
test1:
tasks:
- id: task1
...
- id: task2
...

Test execution phases

A test has three execution phases: beforeAll, tests, and afterAll.

  • The beforeAll phase is executed before the tests in the test run. This phase can be used to set up the application state before running the tests.
  • The tests phase is where the actual tests are run.
  • The afterAll phase is executed after the tests in the test run. This phase can be used to reset or clean up the application state after running the tests.

drawing

Task

A task is a functional element that performs a specific action, such as making an HTTP request or running a query on a database. A task has several execution phases, including resource, beforeScript, action, validate, and afterScript.

Execution phases of a task

A task in TesmonLang has five execution phases: resources, beforeScript, action, validate, and afterScript.

  • resources phase is the first phase of the task execution and is used to establish a connection to a resource, such as a database or Kafka.
  • beforeScript phase is executed before the action in the task and is used to set up the state before the action is executed.
  • action phase is the actual action of the task, such as HTTP call or database query.
  • validate phase is executed after the action in the task and is used to validate the action output.
  • afterScript phase is executed after the action in the task and is used to set up the context for the next task.

drawing

Example code

tasks:
- id: task1
beforeScript: ...
resource: ...
action: ...
afterScript: ...
validate: ...