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

Set the correct detail message for passed steps (fix #835) by sharovd · Pull Request #853 · 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  (2) 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
22 changes: 14 additions & 8 deletions allure-robotframework/src/listener/allure_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 @@ -106,9 +106,10 @@ def start_before_fixture(self, name):
fixture.name = name

def stop_before_fixture(self, attributes, messages):
self._report_messages(messages)
status = attributes.get('status')
self._report_messages(status, messages)
with self.lifecycle.update_before_fixture() as fixture:
fixture.status = get_allure_status(attributes.get('status'))
fixture.status = get_allure_status(status)
fixture.statusDetails = StatusDetails(message=self._current_msg, trace=self._current_tb)
self.lifecycle.stop_before_fixture()

Expand All @@ -117,9 +118,10 @@ def start_after_fixture(self, name):
fixture.name = name

def stop_after_fixture(self, attributes, messages):
self._report_messages(messages)
status = attributes.get('status')
self._report_messages(status, messages)
with self.lifecycle.update_after_fixture() as fixture:
fixture.status = get_allure_status(attributes.get('status'))
fixture.status = get_allure_status(status)
fixture.statusDetails = StatusDetails(message=self._current_msg, trace=self._current_tb)
self.lifecycle.stop_after_fixture()

Expand All @@ -136,7 +138,7 @@ def start_test(self, name, attributes):
container.children.append(uuid)

def stop_test(self, _, attributes, messages):
self._report_messages(messages)
self._report_messages(attributes.get('status'), messages)

if 'skipped' in [tag.lower() for tag in attributes['tags']]:
attributes['status'] = RobotStatus.SKIPPED
Expand Down Expand Up @@ -168,17 +170,21 @@ def start_keyword(self, name):
step.name = name

def stop_keyword(self, attributes, messages):
self._report_messages(messages)
status = attributes.get('status')
self._report_messages(status, messages)
with self.lifecycle.update_step() as step:
step.status = get_allure_status(attributes.get('status'))
step.status = get_allure_status(status)
step.parameters = get_allure_parameters(attributes.get('args'))
step.statusDetails = StatusDetails(message=self._current_msg, trace=self._current_tb)
self.lifecycle.stop_step()

def _report_messages(self, messages):
def _report_messages(self, status, messages):
has_trace = BuiltIn().get_variable_value("${LOG LEVEL}") in (RobotLogLevel.DEBUG, RobotLogLevel.TRACE)
attachment = ""

if status == RobotStatus.PASSED:
self._current_tb, self._current_msg = None, None

for message, next_message in zip_longest(messages, messages[1:]):
name = message.get('message')
level = message.get('level')
Expand Down
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 @@ -99,3 +99,73 @@ def test_steps_after_failed_are_skipped(docstring, robot_runner: AllureRobotRunn
)
)
)


def test_only_failed_steps_have_status_details(docstring, robot_runner: AllureRobotRunner):
"""
*** Variables ***
@{TEST_VALUES} 0 5 15

*** Test Cases ***
Test Case with mixed step results and status details
FOR ${value} IN @{TEST_VALUES}
Run Keyword And Ignore Error Should Be True ${value} > 10
END
Log To Console Test message
"""

robot_runner.run_robotframework(
suite_literals={"status.robot": docstring}
)

assert_that(
robot_runner.allure_results,
has_test_case(
"Test Case with mixed step results and status details",
has_step(
"${value} IN @{TEST_VALUES}",
has_step(
"${value} = 0",
has_step(
"BuiltIn.Run Keyword And Ignore Error",
has_step(
"BuiltIn.Should Be True",
with_status("failed"),
has_status_details(
with_message_contains("0 > 10' should be true."),
)
),
),
),
has_step(
"${value} = 5",
has_step(
"BuiltIn.Run Keyword And Ignore Error",
has_step(
"BuiltIn.Should Be True",
with_status("failed"),
has_status_details(
with_message_contains("5 > 10' should be true."),
)
),
),
),
has_step(
"${value} = 15",
has_step(
"BuiltIn.Run Keyword And Ignore Error",
has_step(
"BuiltIn.Should Be True",
with_status("passed"),
has_status_details({})
),
),
)
),
has_step(
"BuiltIn.Log To Console",
with_status("passed"),
has_status_details({})
)
)
)

Back | FazBrowse Home | New Git URL