Comparison
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.
Example code
tests:
test1:
tasks:
- ...
- ...
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.
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 theaction
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 theaction
in the task and is used to validate the action output.afterScript
phase is executed after theaction
in the task and is used to set up the context for the next task.
Example code
tasks:
- beforeScript: ...
resource: ...
action: ...
afterScript: ...
validate: ...
📄️ 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.
🗃️ Scripts
4 items
📄️ Context
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.
📄️ Mocks
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.
📄️ Files
When using TesmonLang to make HTTP requests or to send messages with Kafka, you can include the content of a file as part of the request. This is particularly useful for dynamic data that changes frequently or for large data sets that are not practical to include directly in the DSL. This is advantageous in various scenarios, especially when dealing with content that cannot be easily copy-pasted. This includes binary data, various document formats (e.g., PDF, DOCX), image files (e.g., PNG, JPEG), and other media types (e.g., audio and video files). Utilizing external files for the request body facilitates easy updates and management of the content.