FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Set testCaseId for all test results produced by allure_behave by delatrie · Pull Request #883 · allure-framework/allure-python · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (3) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 2 additions & 0 deletions allure-behave/src/listener.py
This file contains hidden or 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
Expand Up @@ -2,6 +2,7 @@
import allure_commons
from allure_commons.reporter import AllureReporter
from allure_commons.utils import uuid4
from allure_commons.utils import md5
from allure_commons.utils import now
from allure_commons.utils import platform_label
from allure_commons.types import LabelType, AttachmentType, LinkType
Expand Down Expand Up @@ -80,6 +81,7 @@ def start_scenario(self, scenario):
test_case.fullName = get_fullname(scenario)
test_case.titlePath = get_title_path(scenario)
test_case.historyId = scenario_history_id(scenario)
test_case.testCaseId = md5(test_case.fullName)
test_case.description = '\n'.join(scenario.description)
test_case.parameters = scenario_parameters(scenario)

Expand Down
4 changes: 4 additions & 0 deletions allure-python-commons-test/src/result.py
This file contains hidden or 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
Expand Up @@ -233,5 +233,9 @@ def has_history_id(matcher=None):
return has_entry('historyId', matcher or anything())


def has_test_case_id(matcher=None):
return has_entry('testCaseId', matcher or anything())


def has_full_name(matcher):
return has_entry("fullName", matcher)
This file contains hidden or 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
@@ -1,9 +1,14 @@
import pytest
from hamcrest import assert_that
from hamcrest import contains_string
from hamcrest import all_of
from tests.allure_behave.behave_runner import AllureBehaveRunner
from allure_commons_test.report import has_test_case
from allure_commons_test.result import with_status
from allure_commons_test.result import has_step
from allure_commons_test.result import has_full_name
from allure_commons_test.result import has_test_case_id
from allure_commons_test.result import has_history_id


@pytest.mark.parametrize(["step", "status"], [
Expand Down Expand Up @@ -140,3 +145,32 @@ def test_nameless_scenario(docstring, behave_runner: AllureBehaveRunner):
with_status("passed")
)
)


def test_identifiers_are_set(docstring, behave_runner: AllureBehaveRunner):
"""
Feature: Foo

Scenario: Bar:
Given noop
"""

behave_runner.run_behave(
feature_literals=[docstring],
step_literals=["given('noop')(lambda c:None)"]
)

assert_that(
behave_runner.allure_results,
has_test_case(
"Bar",
has_full_name(
all_of(
contains_string("Foo"),
contains_string("Bar"),
),
),
has_test_case_id(),
has_history_id(),
),
)
Loading

Back | FazBrowse Home | New Git URL