Allure Pytest configuration

The Allure Pytest adapter provides some additional configuration options that you can pass to pytest. These options affect how Allure Pytest collects the test results and how pytest itself selects which tests to run.

To pass an option, you can just add it to the command when running pytest. For example:

Bash
python -m pytest --clean-alluredir

However, if you want some options to be applies for all pytest runs, add them to the pytest's addopts configuration option. It must be declared in the pytest.ini file in the same directory where you run pytest from. Here's an example of a pytest.ini configuration file:

Text
[pytest] addopts = --clean-alluredir --alluredir allure-results

Options affecting results collection

--alluredir ⟨DIRECTORY⟩

Path to the directory where Allure Pytest will save the test results, see How it works. If the directory does not exist, it will be created. Defaults to allure-results.

--clean-alluredir

If set, the directory specified by --alluredir will be cleaned before generating new test results.

By default, the existing data is kept intact, which allows combining results of multiple test runs into a single test report.

--allure-no-capture

If set, Allure Pytest will not automatically produce the stdout, stderr and log attachments, described in Attach screenshots and other files.

Define a link pattern — a template that can be used to construct full URLs from short identifiers, see reference.

The option accepts two values, separated by a colon.

  • TYPE is an arbitrary string identifier.
  • PATTERN is a string containing {} at the position where the identifier should be placed.

The given PATTERN will be applied when processing any link of the given TYPE. You can use the option multiple times, thus defining multiple link patterns for different link types.

For example, here's a way to define a link pattern for issues in a GitHub repository:

Bash
python -m pytest --allure-link-pattern issue:https://github.com/allure-framework/allure-python/issues/{}

Options affecting test selection

Each one of these options, except for --inversion, accepts a comma-separated list of values that narrow down the selection of tests pytest should run. When two or more of such options are used together, pytest will run tests matching any of the conditions.

The options don't work with the metadata added dynamically inside the code of the tests, see Specify description, links and other metadata.

--allure-severities ⟨SEVERITY1⟩,⟨SEVERITY2⟩,...

Only run tests that have one of the specified severity values, see Specify description, links and other metadata.

--allure-epics ⟨EPIC1⟩,⟨EPIC2⟩,...

Only run tests that have one of the specified epic values, see Behavior-based hierarchy.

--allure-features ⟨FEATURE1⟩,⟨FEATURE2⟩,...

Only run tests that have one of the specified feature values, see Behavior-based hierarchy.

--allure-stories ⟨STORY1⟩,⟨STORY2⟩,...

Only run tests that have one of the specified story values, see Behavior-based hierarchy.

--allure-ids ⟨ID1⟩,⟨ID2⟩,...

Only run tests that have one of the specified IDs, see Specify description, links and other metadata.

--allure-label ⟨LABEL1⟩=⟨VALUE1⟩,⟨LABEL2⟩=⟨VALUE2⟩,...

Only run tests that have one of the specified labels, see Specify description, links and other metadata.

--inversion

If set, pytest will only run the tests that do not match the conditions specified by other arguments or the test plan.

Powered by
logo

Join our newsletter

Join our community

We aim to make Allure Report as reliable and user-friendly as possible, and together with the community, we're here to help when problems arise.

© 2024 Qameta Software Inc. All rights reserved.