-
Download the SDK using one of the following commands:
pip install perfecto-py3
easy_install perfecto-py3
(Just for illustrating it will be available asap). -
imports:
from reporting import TestContext, PerfectoReportiumClient, PerfectoExecutionContext, TestResultFactory
- Creating reporting client (use client as instance variable):
def create_reporting_client(self):
perfecto_execution_context = PerfectoExecutionContext(self.driver)
self.reporting_client = PerfectoReportiumClient(perfecto_execution_context)
- Starting a new test (first sample unittest, second is freestyle):
unittest (will use the method name as the test's name):
self.reporting_client.test_start(self.id(),
TestContext('tag1', 'tag2', 'tag3'))
freestyle:
self.reporting_client.test_start('Test name', TestContext('tags params'))
- Log a new test step:
self.reporting_client.test_step('Description')
- End test (Unittest):
def tearDown(self):
try:
if self.currentResult.wasSuccessful():
self.reporting_client.test_stop(TestResultFactory.create_success())
else:
self.reporting_client.test_stop(TestResultFactory.create_failure(self.currentResult.errors,
self.currentResult.failures))
# Print(report's url)
print('Report-Url: ' + self.reporting_client.report_url() + '\n')
except Exception as e:
print(str(e)
self.driver.quit()
Code samples at https://github.com/PerfectoCode/Reporting-Samples/tree/master/Python