-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor tests to use pytest as a test runner for all the packages (#732
- Loading branch information
Showing
376 changed files
with
10,315 additions
and
6,542 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,7 @@ | |
*.egg-info | ||
|
||
*/build | ||
*/dist | ||
*/dist | ||
|
||
/.allure-report | ||
/.allure-results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
=========== | ||
Attachments | ||
=========== | ||
|
||
You can attach data and files to behave test results. An attachment can be added | ||
from a step definition function or from a hook. See examples below for more | ||
details. | ||
|
||
---------------------------------- | ||
Attach data from a step definition | ||
---------------------------------- | ||
|
||
The easiest way to add an attachment is to call the :code:`allure.attach` | ||
function from a step definition: | ||
|
||
Feature file: | ||
^^^^^^^^^^^^^ | ||
.. code:: gherkin | ||
:name: data-attachment-feature | ||
Feature: Allure attachments in behave tests | ||
Scenario: Data attachment from step definitions | ||
Given a step that adds a named attachment | ||
And a step that adds a typed named attachment | ||
Step definition file: | ||
^^^^^^^^^^^^^^^^^^^^^ | ||
.. code:: python | ||
:name: data-attachment-steps | ||
import allure | ||
from behave import given | ||
@given("a step that adds a named attachment") | ||
def step_impl(context): | ||
allure.attach( | ||
"This is the attachment with the name 'step.txt'", | ||
name="step.txt" | ||
) | ||
@given("a step that adds a typed named attachment") | ||
def step_impl(context): | ||
allure.attach( | ||
( | ||
"[DEBUG] This attachment is named 'trace.log' and has TEXT " | ||
"document appearance" | ||
), | ||
name="trace.log", | ||
attachment_type=allure.attachment_type.TEXT | ||
) | ||
---------------------------------- | ||
Attach file from a step definition | ||
---------------------------------- | ||
|
||
Call the :code:`allure.attach.file` function to attach a file: | ||
|
||
Feature file: | ||
^^^^^^^^^^^^^ | ||
.. code:: gherkin | ||
:name: file-attachment-feature | ||
Feature: Allure attachments in behave tests | ||
Scenario: File attachment from a step definition | ||
Given a step that attaches a file | ||
Step definition file: | ||
^^^^^^^^^^^^^^^^^^^^^ | ||
.. code:: python | ||
:name: file-attachment-steps | ||
import allure | ||
from behave import given | ||
@given("a step that attaches a file") | ||
def step_impl(context): | ||
allure.attach.file( | ||
"./logs/web", | ||
name="web.log", | ||
attachment_type=allure.attachment_type.TEXT | ||
) | ||
------------------ | ||
Attach from a hook | ||
------------------ | ||
|
||
You can also attach data and files from a behave hook, e.g., from the | ||
:code:`after_scenario`: | ||
|
||
.. code:: python | ||
:name: attach-hook | ||
import allure | ||
def after_scenario(context, scenario): | ||
allure.attach( | ||
"This attachment will appear on a scenario level", | ||
name="attachment.txt", | ||
attachment_type=allure.attachment_type.TEXT | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
===================================== | ||
Provide a description for a test case | ||
===================================== | ||
|
||
Scenario description can be added in various ways: | ||
|
||
#. In a .feature file | ||
#. Dynamically in a step definition | ||
#. Dynamically in a hook (e.g., before_scenario or after_scenario) | ||
|
||
----------------------------- | ||
Description in a feature file | ||
----------------------------- | ||
|
||
The easiest way to add a description to a test is to specify it directly in the | ||
corresponding scenario in the .feature file. For example: | ||
|
||
.. code-block:: gherkin | ||
:name: description-in-feature-feature | ||
Feature: Allure description for behave tests | ||
Scenario: Description from a .feature file | ||
This scenario has a description. | ||
This description spans across multiple lines. | ||
Given noop | ||
The step definition is trivial: | ||
|
||
.. code-block:: python | ||
:name: description-in-feature-steps | ||
from behave import given | ||
@given("noop") | ||
def step_impl(context): | ||
pass | ||
------------------- | ||
Dynamic description | ||
------------------- | ||
|
||
A description can be specified dynamically with the | ||
:code:`allure.dynamic.description` function. This is useful if you want to | ||
include runtime values in the description. | ||
|
||
|
||
Description in a step definition | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
Let's suppose, we want to add a description to the following test: | ||
|
||
.. code-block:: gherkin | ||
:name: description-in-step-feature | ||
Feature: Allure description for behave tests | ||
Scenario: Description from a step definition | ||
Given description is provided in a step definition | ||
We can achieve that using the following step definition: | ||
|
||
.. code-block:: python | ||
:name: description-in-step-steps | ||
from behave import given | ||
import allure | ||
@given("description is provided in a step definition") | ||
def step_impl(context): | ||
allure.dynamic.description( | ||
"This scenario has a description specified by the step definition" | ||
) | ||
Description in a hook | ||
^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
It's also possible to add a description from a hook in the | ||
:code:`environment.py` file. | ||
|
||
Suppose we have the following feature file (and step definition is the same as | ||
in `Description in a feature file`_): | ||
|
||
.. code-block:: gherkin | ||
:name: description-in-hook-feature | ||
Feature: Allure description for behave tests | ||
Scenario: Description from the before_scenario hook | ||
Given noop | ||
Scenario: Description from the after_scenario hook | ||
Given noop | ||
We can provide a description in the :code:`environment.py` like this: | ||
|
||
.. code-block:: python | ||
:name: description-in-hook-env | ||
import allure | ||
def before_scenario(context, scenario): | ||
if "before_scenario" in scenario.name: | ||
allure.dynamic.description( | ||
"This scenario has a description specified in the " | ||
"before_scenario hook" | ||
) | ||
def after_scenario(context, scenario): | ||
if "after_scenario" in scenario.name: | ||
allure.dynamic.description( | ||
"This scenario has a description specified in the " | ||
"after_scenario hook" | ||
) |
Oops, something went wrong.