@@ -33,6 +33,7 @@ def __init__(self, behave_config):
3333 self .behave_config = behave_config
3434 self .logger = AllureReporter ()
3535 self .current_step_uuid = None
36+ self .current_scenario_uuid = None
3637 self .execution_context = Context ()
3738 self .fixture_context = Context ()
3839 self .steps = deque ()
@@ -82,12 +83,15 @@ def stop_feature(self):
8283
8384 @allure_commons .hookimpl
8485 def start_test (self , parent_uuid , uuid , name , parameters , context ):
85- scenario = context ['scenario' ]
86+ self .start_scenario (context ['scenario' ])
87+
88+ def start_scenario (self , scenario ):
89+ self .current_scenario_uuid = uuid4 ()
8690 self .fixture_context .enter ()
8791 self .execution_context .enter ()
88- self .execution_context .append (uuid )
92+ self .execution_context .append (self . current_scenario_uuid )
8993
90- test_case = TestResult (uuid = uuid , start = now ())
94+ test_case = TestResult (uuid = self . current_scenario_uuid , start = now ())
9195 test_case .name = scenario_name (scenario )
9296 test_case .historyId = scenario_history_id (scenario )
9397 test_case .description = '\n ' .join (scenario .description )
@@ -98,31 +102,34 @@ def start_test(self, parent_uuid, uuid, name, parameters, context):
98102 test_case .labels .append (Label (name = LabelType .FRAMEWORK , value = 'behave' ))
99103 test_case .labels .append (Label (name = LabelType .LANGUAGE , value = platform_label ()))
100104
101- self .logger .schedule_test (uuid , test_case )
105+ self .logger .schedule_test (self . current_scenario_uuid , test_case )
102106
103107 @allure_commons .hookimpl
104108 def stop_test (self , parent_uuid , uuid , name , context , exc_type , exc_val , exc_tb ):
105- scenario = context ['scenario' ]
109+ self .stop_scenario (context ['scenario' ])
110+
111+ def stop_scenario (self , scenario ):
106112 if scenario .status == 'skipped' and not self .behave_config .show_skipped :
107- self .logger .drop_test (uuid )
113+ self .logger .drop_test (self . current_scenario_uuid )
108114 else :
109115 status = scenario_status (scenario )
110116 status_details = scenario_status_details (scenario )
111117
112118 self .flush_steps ()
113- test_result = self .logger .get_test (uuid )
119+ test_result = self .logger .get_test (self . current_scenario_uuid )
114120 test_result .stop = now ()
115121 test_result .status = status
116122 test_result .statusDetails = status_details
117- self .logger .close_test (uuid )
123+ self .logger .close_test (self . current_scenario_uuid )
118124 self .current_step_uuid = None
119125
120126 for group in self .fixture_context .exit ():
121- group .children .append (uuid )
127+ group .children .append (self . current_scenario_uuid )
122128 self .logger .stop_group (group .uuid )
123129
124130 self .execution_context .exit ()
125- self .execution_context .append (uuid )
131+ self .execution_context .append (self .current_scenario_uuid )
132+ self .current_scenario_uuid = None
126133
127134 def schedule_step (self , step ):
128135 self .steps .append (step )
0 commit comments