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.
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.
- id: task1
- id: task2
Test execution phases
A test has three execution phases:
beforeAllphase is executed before the tests in the test run. This phase can be used to set up the application state before running the tests.
testsphase is where the actual tests are run.
afterAllphase 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.
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:
resourcesphase is the first phase of the task execution and is used to establish a connection to a resource, such as a database or Kafka.
beforeScriptphase is executed before the
actionin the task and is used to set up the state before the action is executed.
actionphase is the actual action of the task, such as HTTP call or database query.
validatephase is executed after the
actionin the task and is used to validate the action output.
afterScriptphase is executed after the
actionin the task and is used to set up the context for the next task.
- id: task1
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.
Context refers to the execution state of a test and can be used to save and retrieve data during the test's runtime. It is unique to each test and is not available outside of its runtime. Context is a dictionary and can be set and referenced by a script during various phases of a test and a task. However, it is important to note that context set during one phase of a task cannot be referenced in a different phase of the same task.
Tesmon provides a powerful event-driven architecture to help you integrate your tests and gain insights into their execution. The expect task in TesmonLang allows you to validate the occurrence of an event within a specified timeframe.
Tesmon provides a range of powerful mocking capabilities, with HTTP mock being one of the initial features. These mocking capabilities allow you to simulate different scenarios during test execution, enabling you to create comprehensive test cases and validate your system's behavior under various conditions.
📄️ Environment Variables
Environment variables can be set in Test Run Engine (TRE) during its deployments, such as secrets (e.g., database passwords) or configurations to use in a test. More details on setting them can be found in Deploy TRE.
📄️ Time Taken
With Tesmon, performance can be measured during development and testing, and does not have to be an afterthought. The Time Taken feature allows you to measure the response time of your APIs without any instrumentation, and can be used to monitor performance over time.