-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #201 from reportportal/develop
Release
- Loading branch information
Showing
11 changed files
with
118 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
*** Settings *** | ||
Documentation Example of setting Test Case ID in runtime | ||
Library library/TestCaseId.py | ||
|
||
*** Test Cases *** | ||
Test set dynamic Test Case ID | ||
Case Id dynamic_tags.robot[{scope_var}] |
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,38 @@ | ||
"""Test Case ID library for Robot Framework.""" | ||
# Copyright 2024 EPAM Systems | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from typing import Optional | ||
|
||
from robot.libraries.BuiltIn import BuiltIn | ||
|
||
|
||
def case_id(test_case_id_pattern: Optional[str]) -> None: | ||
""" | ||
Set test case ID based on suite metadata. | ||
:param test_case_id_pattern: Test Case ID pattern | ||
""" | ||
built_in = BuiltIn() | ||
if not test_case_id_pattern: | ||
return | ||
suite_metadata = built_in.get_variable_value('${suitemetadata}') | ||
scope = None | ||
for key in suite_metadata: | ||
if key.lower() == 'scope': | ||
scope = suite_metadata[key] | ||
break | ||
if not scope: | ||
return | ||
built_in.set_tags('test_case_id:' + test_case_id_pattern.format(scope_var=scope)) |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Basic dependencies | ||
python-dateutil~=2.8.1 | ||
reportportal-client~=5.5.7 | ||
reportportal-client~=5.5.8 | ||
robotframework |
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
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 |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
from setuptools import setup | ||
|
||
|
||
__version__ = '5.5.6' | ||
__version__ = '5.5.7' | ||
|
||
|
||
def read_file(fname): | ||
|
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,41 @@ | ||
# Copyright 2024 EPAM Systems | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from unittest import mock | ||
|
||
from tests import REPORT_PORTAL_SERVICE | ||
from tests.helpers import utils | ||
|
||
EXAMPLE_TEST = 'examples/dynamic_test_case_id.robot' | ||
|
||
|
||
@mock.patch(REPORT_PORTAL_SERVICE) | ||
def test_case_id_simple(mock_client_init): | ||
result = utils.run_robot_tests([EXAMPLE_TEST], arguments={'--metadata': 'Scope:Smoke'}) | ||
assert result == 0 # the test successfully passed | ||
|
||
mock_client = mock_client_init.return_value | ||
launch_start = mock_client.start_launch.call_args_list | ||
launch_finish = mock_client.finish_launch.call_args_list | ||
assert len(launch_start) == len(launch_finish) == 1 | ||
|
||
item_start_calls = mock_client.start_test_item.call_args_list | ||
item_finish_calls = mock_client.finish_test_item.call_args_list | ||
assert len(item_start_calls) == len(item_finish_calls) == 3 | ||
|
||
test_item_start = item_start_calls[-2] | ||
assert test_item_start[1]['test_case_id'] == f'{EXAMPLE_TEST}:Test set dynamic Test Case ID' | ||
|
||
test_item_finish = item_finish_calls[-2] | ||
assert test_item_finish[1]['test_case_id'] == 'dynamic_tags.robot[Smoke]' |