Messaging Commands - TestlumFramework/Testlum GitHub Wiki
Testlum supports direct interaction with messaging services such as SendGrid, SES, SMTP, and Twilio.
You can send emails, SMS, or perform messaging actions as part of your automated scenarios.
Each service has a dedicated command with simple, intuitive parameters for configuration and usage.
- π§ SendGrid
- βοΈ SES (Simple Email Service)
- π€ SMTP
- π Twilio
SendGrid
The sendgrid command allows you to interact with the SendGrid API inside your test scenarios.
You can send emails, retrieve statistics, manage templates, and more.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
comment |
String | β | - | Description of the SendGrid request |
alias |
String | β | - | Unique name from your integration.xml setup |
condition |
Boolean | β | - | Condition to execute this step |
threshold |
Integer (ms) | β | - | Max allowed time for execution (failure if exceeded) |
Each SendGrid method block (<get>, <post>, <put>, <delete>, <patch>) may contain the following sections:
<post endpoint="/templates">
-
endpointβ API endpoint for your SendGrid request.
| Parameter | Description |
|---|---|
code |
Expected HTTP response code (e.g., 200, 201). |
file |
File with the expected JSON/XML response. |
<response code="201" file="expected_1.json"/>
| Parameter | Description |
|---|---|
name |
Header name (e.g., Authorization) |
data |
Header value (e.g., Bearer YOUR_TOKEN) |
<header name="Authorization" data="Bearer YOUR_TOKEN"/>
You can pass a request body from a JSON file:
<body> <from file="request_1.json"/> </body>
Or, you can write the request body directly:
<body> <raw> { "name": "example_name", "generation": "legacy" } </raw> </body>
| Parameter | Description |
|---|---|
name |
Field name (e.g., subject) |
data |
Field value (e.g., Test Email) |
Use <param> inside <body> to define key-value pairs dynamically.
They are auto-converted based on your request Content-Type.
| Parameter | Description |
|---|---|
file |
Path to the file |
name |
Form field key (e.g., file) |
fileName |
File name to upload as |
contentType |
MIME type of the file |
<body> <multipart> <file name="uploadFile" fileName="doc.pdf" contentType="application/pdf"/> </multipart> </body>
You can also specify URL query parameters:
| Parameter | Description |
|---|---|
key |
Query parameter name |
value |
Query parameter value |
<queryParam key="limit" value="10"/>
Inside SendGrid methods, always follow this sequence:
- response
- header
- body (from, raw, param)
- multipart
- queryParam
β This ensures correct request building and predictable validation!
<sendgrid comment="Testing post method" alias="ALIAS"> <post endpoint="/templates"> <response code="201" file="expected_1.json"/> <body> <raw> { "name": "example_name", "generation": "legacy" } </raw> </body> </post> </sendgrid> <var comment="Create variable for templates id token" name="template_id"> <path value="$.id"/> </var> <sendgrid comment="Testing get method" alias="ALIAS"> <get endpoint="/templates/{{template_id}}"> <response code="200" file="expected_3.json"/> <header name="Content-Type" data="application/json"/> </get> </sendgrid>
π Tip:
Use variables ({{template_id}}) to dynamically pass data between requests inside your test scenarios!
SES
Description:
The<ses>command allows you to send emails using Amazon SES (Simple Email Service) in your Testlum scenarios. It supports sending both HTML and plain-text email content to one or more recipients.
This tag is used to send an email using SES.
| Parameter | Type | Required | Description |
|---|---|---|---|
comment |
String | β | Description of the email action being performed |
alias |
String | β | Unique alias for the SES connection configured in integration.xml
|
destination |
String | β | Recipient email(s) for the message |
source |
String | β | Sender's verified email address in SES |
message |
Object | β | Contains the email body (html, text) and the subject
|
body |
Object | β | The body content, which can include both html and text formats |
html |
String | β | HTML body content for the email |
text |
String | β | Plain-text content for the email |
subject |
String | β | Subject line of the email |
condition |
Boolean | β | Optional condition to determine when this test step will execute |
threshold |
Integer (ms) | β | Optional time limit for execution (in milliseconds). |
<ses comment="Sending a message to the email" alias="ALIAS"> <destination>[email protected]</destination> <source>[email protected]</source> <message> <body> <html>Amazon SES test</html> <text>Hello World</text> </body> <subject>TITLE</subject> </message> </ses>
β Tips:
- Use
destinationto specify multiple recipients by separating emails with commas.- Ensure
sourceis a verified SES email address.- Always validate the
subject,html, andtextcontent to ensure proper email delivery formatting.
SMTP
Description:
The<smtp>command sends an email via SMTP protocol in your Testlum scenarios.
This tag is responsible for sending SMTP emails with specified parameters.
| Parameter | Type | Required | Description |
|---|---|---|---|
alias |
String | β | Unique alias for the SMTP connection configured in integration.xml
|
comment |
String | β | Description of the email action being performed |
recipientEmail |
String | β | The recipient email address |
subject |
String | β | Subject of the email |
text |
String | β | Content of the email |
condition |
Boolean | β | Optional condition to determine when this test step will be executed |
threshold |
Integer (ms) | β | Maximum allowed execution time for this step |
<smtp comment="Testing smtp work" alias="ALIAS" recipientEmail="[email protected]"> <subject>Test subject</subject> <text>Test text</text> </smtp>
β Tips:
- Ensure that the
recipientEmailis valid.- If the
conditionis used, set it for conditional execution of the step.- Use
thresholdto define how long the system should wait for the email sending process.
Twilio
Description:
The<twilio>command allows you to send SMS messages via Twilio in your Testlum scenarios.
This tag is responsible for sending text messages through Twilioβs API.
| Parameter | Type | Required | Description |
|---|---|---|---|
alias |
String | β | Unique alias for the Twilio API configuration in integration.xml
|
comment |
String | β | Description of the SMS sending action |
destinationPhoneNumber |
String | β | The recipientβs phone number (in E.164 format, e.g., +380631111111) |
message |
String | β | Content of the SMS message |
condition |
Boolean | β | Optional condition for executing the step |
threshold |
Integer (ms) | β | Maximum allowed execution time for the step (in milliseconds) |
<twilio comment="Test how Twilio works" alias="ALIAS" destinationPhoneNumber="+380631111111"> <message>Testlum!</message> </twilio>
β Tips:
- Use
destinationPhoneNumberto specify the phone number for the message (ensure it's in E.164 format).- Set the
thresholdfor defining the maximum time allowed for sending the message.- Use
conditionfor conditional execution of the test step.