
testomat.io plugin for pytest
A powerful pytest plugin that integrates your tests with testomat.io platform for test management, reporting and analytics
Features
- โ
Sync tests with testomat.io
- ๐ Real-time test execution reporting
- ๐ท๏ธ Test labeling and categorization
- ๐ Test run grouping and environments
- ๐ Artifact management with S3 integration
- ๐ Advanced filtering and debugging
uses testomat.io API:
Table of Contents
Installation
Prerequisites:
Install via pip:
pip install pytestomatio
Quick Start
Get your API token
- Login to testomat.io
- Create project or go to existing project
- Click on "Import Tests from Source Code"
- Copy your project token(starts with "tstmt_")
Sync tests
Synchronize tests to testomat.io:
TESTOMATIO=your_token pytest --testomatio sync
Report tests
Execute tests and send results to testomat.io:
TESTOMATIO=your_token pytest --testomatio report
Example of test
To make the experience more consistent, it uses standard pytest markers.
testomat.io test id is a string value that starts with @T and has 8 symbols after.
from pytest import mark
@mark.testomatio('@T96c700e6')
def test_example():
assert 2 + 2 == 4
Advanced usage
Core commands
Synchronization
Synchronize tests to testomat.io and get back test id.
pytest --testomatio sync
Clarification:
- tests will not be executed
- tests can be synced even without
@pytest.mark.testomatio('@T96c700e6') decorator.
- test title in testomat.io == test name in pytest
- test suit title in testomat.io == test file name in pytest
Tagging tests on sync
Since a Python test function name can't contain special characters like @tag, tags are
assigned via the built-in testomatio_tags marker, and are added to the test title on sync:
import pytest
@pytest.mark.testomatio_tags("smoke", "regression")
def test_example():
assert 2 + 2 == 4
This produces a test titled Example @smoke @regression in testomat.io.
You can also reuse plain pytest markers as tags by allowlisting their names via the
TESTOMATIO_TAG_MARKERS env var (comma-separated). We don't pick up every pytest.mark.*
automatically, since that would also catch pytest/plugin service markers like parametrize,
skip, usefixtures, etc. - only markers explicitly listed are treated as tags:
export TESTOMATIO_TAG_MARKERS=smoke,regression
import pytest
@pytest.mark.smoke
def test_example():
assert 2 + 2 == 4
This produces a test titled Example @smoke in testomat.io.
Clean up
Remove all test ids from source code. Tests will not be executed
pytest --testomatio remove
Report
Run pytest and send test results into testomat.io.
Test can be sent to testomat.io without ids in your test code. If testomat.io failed to match tests by title, it will create
new tests for the run
pytest --testomatio report
Debug
Run pytest with debug parameter to get test data collected in metadata.json file
pytest --testomatio debug
Launch
Create empty run and obtain its RUN_ID from testomat.io.
pytest --testomatio launch
Finish
Finish running or scheduled run on testomat.io.
TESTOMATIO_RUN_ID environment variable is required.
TESTOMATIO_RUN_ID=***run_id*** pytest --testomatio finish
Additional options
Submitting Test Run Environment
To configure test environment, you can use additional option testRunEnv. The configured environment will be added to the test report. Use it with report command:
pytest --testomatio report --testRunEnv "windows11,chrome,1920x1080"
Environment values are comma separated, please use double quotation.
Clearing empty test suites
To automatically clean empty test suites on testomat.io you can use no-empty option. Use it with
sync command:
pytest --testomatio sync --no-empty
Disable detaching tests
If a test from a previous import was not found on next import it is marked as "detached".
This is done to ensure that deleted tests are not staying in Testomatio while deleted in codebase.
To disable this behaviour and don't mark anything as detached on import use no-detach option. Use it with sync command:
pytest --testomatio sync --no-detach
Keeping original file structure
By default, when importing tests, testomat.io does not preserve original file structure. Use option keep-structure with sync command to keep original file structure:
pytest --testomatio sync --keep-structure
Import into given directory
By default, tests are imported into the root of the project.
You can use directory option to specify directory to use for test file structure. Use this option with sync command:
pytest --testomatio sync --directory imported_tests
Note: keep-structure option takes precedence over directory option. If both are used keep-structure will be used.
Filter tests
You can filter tests that will be reported, using testomatio-filter option. Filter format: filter_type=value. Use this option with report command.
Note: Only one filter can be applied at a time
Filter types:
- test_id. Filter test by Testomat.io id. You can pass single or multiple ids for this filter using | as separator. Ex: "test_id=@T3h2r432|T2e34e342|b234fr254"
- plan. Filter by plan id.
- jira. Filter by jira issue id.
- tag. Filter by tag name.
- label. Filter by label name or label-id.
Examples:
Filter by test id
pytest --testomatio report --testomatio-filter="test_id=Tc0880217|Tfd1c595c"
Filter by tag
If your test have '@smoke' tag on testomat.io, then value for this filter == smoke
pytest --testomatio report --testomatio-filter="tag=smoke"
Filter by label
# by label name
pytest --testomatio report --testomatio-filter="label=important"
# by label id
pytest --testomatio report --testomatio-filter="label=important-f435-e"
# based on Severity type
pytest --testomatio report --testomatio-filter="label=severity-f124r-3:โ ๏ธ Critical"
Filter by plan
pytest --testomatio report --testomatio-filter="plan=ca34gf3t"
Filter by Jira Issue
pytest --testomatio report --testomatio-filter="jira=TES1"
Submitting Test Steps
The plugin supports dividing tests into separate, trackable steps. When reporting to testomat.io, you can view detailed information for each step including execution status, duration, and any errors that occurred.
Important: This plugin only supports reporting test steps to testomat.io during test execution. Test steps cannot be imported to testomat.io using sync option. Steps reported for skipped and failed test by default. To enable steps reporting for passed tests use TESTOMATIO_STEPS_PASSED env variable.
Test steps can be implemented using either decorators or context managers, giving you flexibility in how you structure your tests.
Error Handling: If a step fails, the error is captured and reported to testomat.io while the test execution continues with remaining steps.
Parameters:
@step_function(
title = "Step1", # Step name displayed in testomat.io
category = "user" # Optional: categorize steps(user, system, framework)
)
with step(
title = "Step1", # Step name displayed in testomat.io
category = "user" # Optional: categorize steps(user, system, framework)
)
Example:
import pytest
from pytestomatio.utils.steps import step, step_function
class Book:
def __init__(self, author, text):
self.author = author
self.text = text
def read(self):
return self.text
# decorator
@step_function(title='Check author step', category='user')
def check_author(author_name, expected_name):
assert author_name == expected_name
def test_book_create():
author_name = 'David Ket'
# context manager
with step(title='Book create', category='user'):
book = Book(author_name, 'text')
assert book
check_author(book.author, author_name)
# nested steps also supported
def test_book_read():
text = 'book text'
author_name = 'David Ket'
with step(title='Read book'):
with step(title='Book create', category='user'):
book = Book(author_name, 'text')
assert book
check_author(book.author, author_name)
assert book.read() == text
Note: Step is registered when the step code is executed. Therefore, if test mark as skipped(not executed at all) or test code execution stops before step code is executed, step will not be attached to test:
import pytest
from pytestomatio.utils.steps import step
# Step will not be added in report
@pytest.mark.skip
def test_skipped():
with step('Step1', 'user'):
assert True
# Step will not be added in report
def test_exception_raised():
raise ValueError()
with step('Step1', 'user'):
assert True
# Step will not be added in report
def test_early_skip():
pytest.skip()
with step('Step1', 'user'):
assert True
# Step1 will be added in report, Step2 will not be
def test_nested_step_skip_or_exception():
with step('Step1', 'user'):
with step('Step2', 'user'):
pytest.skip() # or AttributeError()
Configuration with environment variables
You can use environment variable to control certain features of testomat.io. Environment variables can be either passed inline, or from .env file.
Basic configuration
| Env variable |
What it does |
Examples |
| TESTOMATIO |
Provides token for pytestomatio to access and push data to testomat.io. Required for sync and report commands |
TESTOMATIO=tstmt_***** pytest --testomatio sync |
| TESTOMATIO_SYNC_LABELS |
Assign labels to a test case when you synchronise test from code with testomat.io. Labels must exist in project and their scope must be enabled for tests |
TESTOMATIO_SYNC_LABELS="number:1,list:one,standalone" pytest --testomatio report |
| TESTOMATIO_CODE_STYLE |
Code parsing style for test synchronization. If you are not sure, don't set this variable. Default value is 'default' |
TESTOMATIO_CODE_STYLE=pep8 pytest --testomatio sync |
| TESTOMATIO_TAG_MARKERS |
Allowlist of bare pytest marker names to treat as tags and append to the test title on sync (comma-separated). See Tagging tests on sync |
TESTOMATIO_TAG_MARKERS=smoke,regression pytest --testomatio sync |
| TESTOMATIO_CI_DOWNSTREAM |
If set, pytestomatio will not set or update build url for a test run. This is useful in scenarios where build url is already set in the test run by Testomat.io for test runs that a created directly on Testomat.io. |
TESTOMATIO_CI_DOWNSTREAM=true pytest --testomatio report |
| TESTOMATIO_URL |
Customize testomat.io url |
TESTOMATIO_URL=https://custom.com/ pytest --testomatio report |
| BUILD_URL |
Overrides build url run tests |
BUILD_URL=http://custom.com/ pytest --testomatio report |
| TESTOMATIO_NO_TIMESTAMP |
Disable automatic timestamp generation for test results. Use this option if you run tests in parallel on different machines where time is not synchronized |
TESTOMATIO_NO_TIMESTAMP=True pytest --testomatio report |
| TESTOMATIO_MAX_REQUEST_FAILURES |
Sets the max number of attempts to send a request to the Testomat.io API. Default is 5 attempts. |
TESTOMATIO_MAX_REQUEST_FAILURES=10 pytest --testomatio report |
| TESTOMATIO_REQUEST_INTERVAL |
Sets the interval between API requests in seconds. Default is 5 sec. |
TESTOMATIO_REQUEST_INTERVAL=2 pytest --testomatio report |
Test Run configuration
| Env variable |
What it does |
Examples |
| TESTOMATIO_TITLE |
Name of a test run to create on testomat.io |
TESTOMATIO_TITLE="Nightly Smoke Tests" pytest --testomatio report |
| TESTOMATIO_RUN_ID |
Id of existing test run to use for sending test results to |
TESTOMATIO_RUN_ID=98dfas0 pytest --testomatio report |