Integrations
Documentation for all the possible integrations.
See Creating Custom Integrations for a step-by-step guide on adding new integrations.
Base integration
- class base_integration.Integration
Base class for lifecycle integrations. Subclasses override only the hooks they need — all hooks are no-ops by default.
- on_run_end(test_results, test_run_id, elapsed_time, log_path=None, context=None)
Called after all tests complete. Override if needed.
- Parameters:
test_results (dict) – Collection of test execution results
test_run_id (str) – Unique test run identifier
elapsed_time (float) – Total test run duration in seconds
log_path (str or None) – Path to the captured console output log file
context (dict or None) – Shared context dict for passing data between integrations
- on_run_start()
Called before test execution begins. Override if needed.
- on_test_end(test_case, result)
Called after each test completes. Override if needed.
- Parameters:
test_case – The test case instance that just finished
result – The test result dict
- required = False
When True, a failed on_run_start() aborts the entire test run instead of just deregistering the integration.
Integration registry
- registry.clear()
Removes all registered integrations.
- registry.get_integrations()
Returns a copy of the registered integrations list.
- Returns:
List of registered integration instances
- Return type:
list
- registry.on_run_end(test_results, test_run_id, elapsed_time, log_path=None)
Calls on_run_end() on all registered integrations with a shared context dict. Each integration can read from and write to context to share data.
- Parameters:
test_results (dict) – Collection of test execution results
test_run_id (str) – Unique test run identifier
elapsed_time (float) – Total test run duration in seconds
log_path (str or None) – Path to the captured console output log file
- registry.on_run_start()
Calls on_run_start() on all registered integrations. Integrations that fail validation are deregistered so their subsequent lifecycle hooks are not called.
If a required integration fails, raises SystemExit to abort the test run.
- registry.on_test_end(test_case, result)
Calls on_test_end() on all registered integrations.
- Parameters:
test_case – The test case instance that just finished
result – The test result dict
- registry.register(integration)
Register an integration instance for lifecycle dispatch.
- Parameters:
integration (Integration) – An Integration subclass instance
Email integration
- class email_integration.EmailIntegration
Base class for email integrations (Mailtrap, mail.tm, etc.). Provides shared polling and link extraction logic. Subclasses must implement _fetch_messages() and _get_message_body().
- poll_for_verification_link(max_wait=60, poll_interval=6, url_prefix=None, recipient_email=None)
Polls for a verification email and extracts the confirmation link.
- Parameters:
max_wait (int) – Maximum time to wait for email in seconds
poll_interval (int) – Time between polling attempts in seconds
url_prefix (str or None) – Optional URL prefix to search for
recipient_email (str or None) – Optional recipient email to filter by (used by Mailtrap)
- Returns:
The verification link URL
- Return type:
str
- Raises:
Exception – If no email is found or verification link cannot be extracted
Slack integration
- class slack_integration.SlackIntegration
Provides automated Slack channel messaging capabilities for test result reporting
- __init__()
Initialize the integration with Slack client
- _create_payload(results, run_time, testrail_run_id=None, test_run_id=None)
Builds JSON payload containing test run information
- Parameters:
results – Aggregated test run statistics
run_time – Human-readable test execution duration
testrail_run_id – Optional TestRail run ID for linking
test_run_id – Test run identifier string
- Type:
Dictionary
- Type:
String
- Type:
Integer or None
- Type:
String or None
- Returns:
None
- _get_button_blocks()
Generates action button blocks for Slack message based on active integration configurations
- Returns:
JSON payload with integration action buttons
- Return type:
Dictionary
- _get_environment_url()
Returns the BASE URL for the current environment
- Returns:
BASE URL string or environment name as fallback
- Return type:
String
- _get_platform_emoji()
Returns the appropriate emoji representing the current platform configuration
- Returns:
Platform emoji string
- Return type:
String
- _post_results(payload)
Publishes message to Slack using REST API endpoint for the configured channel
- Parameters:
payload – Data formatted in Slack block kit structure
- on_run_end(test_results, test_run_id, elapsed_time, log_path=None, context=None)
Lifecycle hook called after all tests complete. Sends test results to Slack. Reads testrail_run_id from context if available.
- Parameters:
test_results – Collection of test execution results
test_run_id – Unique test run identifier
elapsed_time – Total test run duration in seconds
log_path – Path to the captured console output log file (unused by Slack)
context – Shared context dict — reads ‘testrail_run_id’ if present
- on_run_start()
Validates Slack credentials and channel access before tests run.
- report(results, run_time, testrail_run_id=None, test_run_id=None)
Publishes test results to the configured Slack channel specified in
settings.py- Parameters:
results – Aggregated test run statistics
run_time – Human-readable test execution duration
testrail_run_id – Optional TestRail run ID for linking
test_run_id – Test run identifier string
- Type:
Dictionary
- Type:
String
- Type:
Integer or None
- Type:
String or None
- Returns:
None
Saucelabs integration
- class saucelabs_integration.SaucelabsHelper
- static get_saucelabs_appium_remote(test_case, platform)
Configures and returns a webdriver instance for Saucelabs remote execution with appropriate metadata for test organization :param test_case: A QLTY test case instance :type: QLTYTestcase :param platform: Platform identifier for webdriver configuration :type: String :return: Configured webdriver instance for saucelabs execution :rtype: Webdriver
- static post_result(test_case, driver)
Submits test case result to the Saucelabs job record
- Parameters:
test_case (QLTYTestCase) – A QLTY test case for accessing webdriver
driver (Webdriver) – Webdriver for accessing script executor and posting result
TestRail integration
- class testrail_integration.TestRailIntegration
Provides TestRail API integration for test result reporting. Enables creation of test runs and submission of test results to TestRail.
- __init__()
Initialize the TestRail integration with API credentials from settings
- _test_connection()
Tests the connection to TestRail API by making a simple GET request
- Raises:
Exception – If connection fails or credentials are invalid
- add_attachment_to_result(result_id, file_path)
Attaches a file to a specific test result in TestRail. Supports screenshots, logs, and other artifacts for debugging.
- Parameters:
result_id (int) – The ID of the test result (returned by add_result_for_case)
file_path (str) – Absolute path to the file to attach
- Returns:
The attachment response object
- Return type:
dict
- Raises:
Exception – If attachment upload fails
- add_attachment_to_run(run_id, file_path)
Attaches a file to a test run in TestRail.
- Parameters:
run_id (int) – The ID of the test run
file_path (str) – Absolute path to the file to attach
- Returns:
The attachment response object
- Return type:
dict
- Raises:
Exception – If attachment upload fails
- add_result_for_case(run_id, case_id, status, comment=None, elapsed=None)
Adds a test result for a specific test case in a test run. This method should be called at the end of each test case execution.
- Parameters:
run_id (int) – The ID of the test run
case_id (int) – The ID of the test case (e.g., 69 for case C69)
status (str) – The status of the test (passed, failed, blocked, retest, untested)
comment (str) – Comment or error message for the result (optional)
elapsed (str) – Time elapsed in seconds or time string (e.g., “1m 30s”) (optional)
- Returns:
The created test result object
- Return type:
dict
- Raises:
Exception – If adding result fails
Status values: - ‘passed’ or 1: Test passed - ‘blocked’ or 2: Test blocked - ‘untested’ or 3: Test not executed - ‘retest’ or 4: Test needs retest - ‘failed’ or 5: Test failed
- create_test_run(name, description=None, case_ids=None)
Creates a new test run in TestRail with specific test cases or all cases from the suite.
- Parameters:
name (str) – Name of the test run
description (str) – Description of the test run (optional)
case_ids (list[int]) – List of specific test case IDs to include in the run (optional)
- Returns:
The created test run object containing run_id
- Return type:
dict
- Raises:
Exception – If test run creation fails
- on_run_end(test_results, test_run_id, elapsed_time, log_path=None, context=None)
Lifecycle hook called after all tests complete. Creates a TestRail run, submits results, attaches artifacts and console log. Sets context[‘testrail_run_id’] for downstream integrations.
- Parameters:
test_results – Collection of test execution results
test_run_id – Unique test run identifier
elapsed_time – Total test run duration in seconds
log_path – Path to the captured console output log file
context – Shared context dict for passing data between integrations
- on_run_start()
Validates TestRail connection and credentials before tests run.
- static resolve_case_ids(case_map, config)
Resolve which TestRail case IDs apply based on a case map and a configuration object. Filters out None values and evaluates conditional entries against config flags.
- Parameters:
case_map (dict) – Dictionary with ‘core’ (always-included cases) and conditional entries keyed by field name. Each conditional entry has: - ‘case_id’: int or None - ‘config_key’: str (flag name to check on config) - ‘inverted’: bool (optional, include when config value is falsy) - ‘config_list’: str (optional, include when config list is non-empty)
config – Object with a get_value(key, default=None) method
- Returns:
List of applicable TestRail case IDs
- Return type:
list[int]
- update_run(run_id, case_ids)
Updates a test run to include only specific test cases. This is useful for removing untested cases from the run after execution completes.
- Parameters:
run_id (int) – The ID of the test run to update
case_ids (list) – List of test case IDs to include in the run
- Returns:
The updated test run object
- Return type:
dict
- Raises:
Exception – If update fails
Mailtrap integration
- class mailtrap_integration.MailtrapIntegration
Provides Mailtrap email access capabilities for test automation. Enables retrieval and parsing of test emails sent through Mailtrap.
- BASE_URL = 'https://mailtrap.io/api'
- __init__()
Initialize the Mailtrap helper with API credentials from settings
- _fetch_messages()
Retrieves all messages from the Mailtrap inbox.
- Returns:
List of messages
- Return type:
list
- _filter_messages(messages, recipient_email=None)
Filters messages by recipient email address.
- Parameters:
messages – List of message summaries
recipient_email – Recipient email to filter by
- Returns:
Filtered list of messages
- Return type:
list
- _get_message_body(message_id)
Retrieves the full content of a message and returns normalized body.
- Parameters:
message_id (int) – The ID of the message to retrieve
- Returns:
Dict with ‘html’ and ‘text’ string keys
- Return type:
dict
- get_emails_for_recipient(recipient_email, include_content=False)
Retrieves all emails sent to a specific recipient email address.
- Parameters:
recipient_email (str) – The email address of the recipient
include_content (bool) – Whether to fetch full content for each email (default: False)
- Returns:
List of emails sent to the recipient
- Return type:
list
- get_verification_link(recipient_email, max_wait=30, poll_interval=2, url_prefix=None)
Retrieves the verification link from the latest email sent to the provided email address.
- Parameters:
recipient_email (str) – The email address of the recipient
max_wait (int) – Maximum time to wait for email in seconds (default: 30)
poll_interval (int) – Time between polling attempts in seconds (default: 2)
url_prefix (str or None) – Optional URL prefix to search for
- Returns:
The verification link URL extracted from the email
- Return type:
str
- Raises:
Exception – If no email is found or verification link cannot be extracted
Mail.tm integration
- class mailtm_integration.MailTMIntegration
Provides disposable email capabilities for test automation using mail.tm. No API key or configuration required. Creates temporary email accounts and retrieves messages sent to them — useful for verifying registration flows in production environments where Mailtrap cannot be used.
- Usage:
mail = MailTMIntegration() email = mail.email # e.g., ‘a1b2c3d4e5@dollicons.com’
# … use email in registration form …
link = mail.get_verification_link(max_wait=60, url_prefix=’https://example.com/verify/’) driver.get(link)
- BASE_URL = 'https://api.mail.tm'
- __init__()
Initialize the mail.tm integration by creating a disposable email account. Fetches available domains, creates an account, and authenticates automatically.
- _authenticate()
Authenticates with mail.tm and returns a JWT token.
- Returns:
JWT bearer token
- Return type:
str
- _create_account()
Creates a new disposable email account on mail.tm. Updates self.email to the canonical address returned by the API (mail.tm may normalize the address, e.g. stripping periods).
- _fetch_messages()
Retrieves messages from the mail.tm inbox.
- Returns:
List of message summaries
- Return type:
list
- _get_auth_headers()
Returns authorization headers for authenticated API calls.
- Returns:
Headers dict with Bearer token
- Return type:
dict
- _get_domain()
Fetches available domains from mail.tm and returns the first active one.
- Returns:
An active domain string
- Return type:
str
- _get_message_body(message_id)
Retrieves the full content of a message and returns normalized body.
- Parameters:
message_id (str) – The message ID
- Returns:
Dict with ‘html’ and ‘text’ string keys
- Return type:
dict
- get_emails()
Retrieves all emails in the inbox.
- Returns:
List of message summaries
- Return type:
list
- get_verification_link(max_wait=60, poll_interval=6, url_prefix=None)
Polls for a verification email and extracts the confirmation link.
- Parameters:
max_wait (int) – Maximum time to wait for email in seconds (default: 60)
poll_interval (int) – Time between polling attempts in seconds (default: 6)
url_prefix (str or None) – Optional URL prefix to search for (e.g., ‘https://example.com/verify/’)
- Returns:
The verification link URL extracted from the email
- Return type:
str
- Raises:
Exception – If no email is found or verification link cannot be extracted