How to use _add_step_log method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

writer.py

Source:writer.py Github

copy

Full Screen

...11 def _get_test_result(self, test):12 return self.report.get_test(test)13 def _get_suite_result(self, suite):14 return self.report.get_suite(suite)15 def _add_step_log(self, log, event):16 result = self.report.get(event.location)17 assert result, "Cannot find location %s in the report" % event.location18 step = self._lookup_step(event)19 assert step, "Cannot find active step for %s" % event.location20 assert not step.end_time, "Cannot update step '%s', it has already been ended" % step.description21 step.add_log(log)22 @staticmethod23 def _initialize_result(start_time):24 result = Result()25 result.start_time = start_time26 return result27 @staticmethod28 def _initialize_test_result(test, start_time):29 result = TestResult(test.name, test.description)30 result.tags.extend(test.tags)31 result.properties.update(test.properties)32 result.links.extend(test.links)33 result.rank = test.rank34 result.start_time = start_time35 return result36 @staticmethod37 def _finalize_result(result, end_time):38 result.end_time = end_time39 result.status = "passed" if result.is_successful() else "failed"40 def _lookup_step(self, event):41 try:42 return self.active_steps[event.thread_id]43 except KeyError:44 return None45 def on_test_session_start(self, event):46 self.report.start_time = event.time47 def on_test_session_end(self, event):48 self.report.end_time = event.time49 def on_test_session_setup_start(self, event):50 self.report.test_session_setup = self._initialize_result(event.time)51 def on_test_session_setup_end(self, event):52 self._finalize_result(self.report.test_session_setup, event.time)53 def on_test_session_teardown_start(self, event):54 self.report.test_session_teardown = self._initialize_result(event.time)55 def on_test_session_teardown_end(self, event):56 self._finalize_result(self.report.test_session_teardown, event.time)57 def on_suite_start(self, event):58 suite = event.suite59 suite_result = SuiteResult(suite.name, suite.description)60 suite_result.start_time = event.time61 suite_result.tags.extend(suite.tags)62 suite_result.properties.update(suite.properties)63 suite_result.links.extend(suite.links)64 suite_result.rank = suite.rank65 if suite.parent_suite:66 parent_suite_result = self._get_suite_result(suite.parent_suite)67 parent_suite_result.add_suite(suite_result)68 else:69 self.report.add_suite(suite_result)70 def on_suite_end(self, event):71 suite_result = self._get_suite_result(event.suite)72 suite_result.end_time = event.time73 def on_suite_setup_start(self, event):74 suite_result = self._get_suite_result(event.suite)75 suite_result.suite_setup = self._initialize_result(event.time)76 def on_suite_setup_end(self, event):77 suite_result = self._get_suite_result(event.suite)78 self._finalize_result(suite_result.suite_setup, event.time)79 def on_suite_teardown_start(self, event):80 suite_result = self._get_suite_result(event.suite)81 suite_result.suite_teardown = self._initialize_result(event.time)82 def on_suite_teardown_end(self, event):83 suite_result = self._get_suite_result(event.suite)84 self._finalize_result(suite_result.suite_teardown, event.time)85 def on_test_start(self, event):86 test_result = self._initialize_test_result(event.test, event.time)87 suite_result = self._get_suite_result(event.test.parent_suite)88 suite_result.add_test(test_result)89 def on_test_end(self, event):90 test_result = self._get_test_result(event.test)91 self._finalize_result(test_result, event.time)92 def _bypass_test(self, test, status, status_details, time):93 test_result = self._initialize_test_result(test, time)94 test_result.end_time = time95 test_result.status = status96 test_result.status_details = status_details97 suite_result = self._get_suite_result(test.parent_suite)98 suite_result.add_test(test_result)99 def on_test_skipped(self, event):100 self._bypass_test(event.test, "skipped", event.skipped_reason, event.time)101 def on_test_disabled(self, event):102 self._bypass_test(event.test, "disabled", event.disabled_reason, event.time)103 def on_step_start(self, event):104 result = self.report.get(event.location)105 step = Step(event.step_description)106 step.start_time = event.time107 result.add_step(step)108 self.active_steps[event.thread_id] = step109 def on_step_end(self, event):110 step = self._lookup_step(event)111 step.end_time = event.time112 def on_log(self, event):113 self._add_step_log(114 Log(event.log_level, event.log_message, event.time), event115 )116 def on_check(self, event):117 self._add_step_log(118 Check(event.check_description, event.check_is_successful, event.check_details, event.time), event119 )120 def on_log_attachment(self, event):121 self._add_step_log(122 Attachment(event.attachment_description, event.attachment_path, event.as_image, event.time), event123 )124 def on_log_url(self, event):125 self._add_step_log(126 Url(event.url_description, event.url, event.time), event...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Lemoncheesecake automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful