Skip to content

Commit a61a9f4

Browse files
committed
Tests for issue #139
1 parent 844b428 commit a61a9f4

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*** Settings ***
2+
Suite Teardown Log suite tear down
3+
4+
*** Test Cases ***
5+
My first test
6+
Log My first test
7+
8+
*** Keywords ***
9+
Log suite tear down
10+
Log Suite tear down step
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*** Settings ***
2+
Suite Setup Log suite setup
3+
4+
*** Test Cases ***
5+
My first test
6+
Log My first test
7+
8+
*** Keywords ***
9+
Log suite setup
10+
Log Suite setup step
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""
2+
Copyright (c) 2022 https://reportportal.io .
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
https://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License
14+
"""
15+
16+
import pytest
17+
from six.moves import mock
18+
19+
from tests import REPORT_PORTAL_SERVICE
20+
from tests.helpers import utils
21+
22+
23+
@pytest.mark.parametrize(
24+
'test, idx_to_check, step_name, suite_name', [
25+
('examples/before_after/before_suite_with_steps.robot', 1,
26+
'Log suite setup', 'Before Suite With Steps'),
27+
('examples/before_after/after_suite_with_steps.robot', 3,
28+
'Log suite tear down', 'After Suite With Steps')
29+
])
30+
@mock.patch(REPORT_PORTAL_SERVICE)
31+
def test_before_after_suite_with_steps(mock_client_init, test, idx_to_check,
32+
step_name, suite_name):
33+
mock_client = mock_client_init.return_value
34+
mock_client.start_test_item.side_effect = utils.item_id_gen
35+
36+
result = utils.run_robot_tests([test])
37+
assert result == 0
38+
39+
launch_start = mock_client.start_launch.call_args_list
40+
launch_finish = mock_client.finish_launch.call_args_list
41+
assert len(launch_start) == len(launch_finish) == 1
42+
43+
item_start_calls = mock_client.start_test_item.call_args_list
44+
item_finish_calls = mock_client.finish_test_item.call_args_list
45+
assert len(item_start_calls) == len(item_finish_calls) == 5
46+
47+
statuses = [finish[1]['status'] for finish in item_finish_calls]
48+
assert statuses == ['PASSED'] * 5
49+
50+
before_suite_start = item_start_calls[idx_to_check][1]
51+
assert before_suite_start['name'].startswith(step_name)
52+
assert before_suite_start['has_stats']
53+
assert before_suite_start['parent_item_id'].startswith(suite_name)

0 commit comments

Comments
 (0)