class Plugin: # pylint: disable=too-few-public-methods def __init__(self): self.backend = Backend(prefix='[TAP]') def parse(self, tap_file, progress_cb=None): self.backend.configure() test_execution_id = None trace_back = [] for line in Parser().parse_file(tap_file): if isinstance(line, Result): # before parsing the 'next' result line add # traceback as comment to the previous TE if test_execution_id and trace_back: self.backend.add_comment(test_execution_id, "\n" + "\n".join(trace_back)) trace_back = [] elif isinstance(line, Diagnostic): trace_back.append(line.text[2:]) continue else: continue test_case, _ = self.backend.test_case_get_or_create( line.description) test_case_id = test_case['id'] self.backend.add_test_case_to_plan(test_case_id, self.backend.plan_id) comment = 'Result recorded via Kiwi TCMS tap-plugin' if line.ok: status_id = self.backend.get_status_id('PASSED') else: status_id = self.backend.get_status_id('FAILED') if line.skip: status_id = self.backend.get_status_id('WAIVED') comment = line.directive.text if line.todo: status_id = self.backend.get_status_id('PAUSED') comment = line.directive.text for execution in self.backend.add_test_case_to_run( test_case_id, self.backend.run_id, ): self.backend.update_test_execution(execution["id"], status_id, comment) if progress_cb: progress_cb() self.backend.finish_test_run()
def __init__(self): self.backend = Backend(prefix='[cucumber] ')
def __init__(self): self.backend = Backend(prefix='[TAP]')
class Plugin: # pylint: disable=too-few-public-methods def __init__(self): self.backend = Backend(prefix='[TAP] ') def parse(self, tap_file, progress_cb=None): self.backend.configure() for line in Parser().parse_file(tap_file): if not isinstance(line, Result): continue test_case = self.backend.test_case_get_or_create(line.description) test_case_id = test_case['case_id'] self.backend.add_test_case_to_plan(test_case_id, self.backend.plan_id) test_case_run_id = self.backend.add_test_case_to_run( test_case_id, self.backend.run_id) comment = 'Result recorded via Kiwi TCMS tap-plugin' if line.ok: status_id = self.backend.get_status_id('PASSED') else: status_id = self.backend.get_status_id('FAILED') if line.skip: status_id = self.backend.get_status_id('WAIVED') comment = line.directive.text if line.todo: status_id = self.backend.get_status_id('PAUSED') comment = line.directive.text self.backend.update_test_case_run(test_case_run_id, status_id, comment) if progress_cb: progress_cb()
def __init__(self): self.backend = Backend(prefix='[junit.xml] ')
class Plugin: # pylint: disable=too-few-public-methods def __init__(self): self.backend = Backend(prefix='[junit.xml] ') def parse(self, junit_xml, progress_cb=None): self.backend.configure() xml = JUnitXml.fromfile(junit_xml) # apparently junit.xml may contain either a <testsuites> tag, # e.g. Katalon Studio if xml._tag == "testsuites": # pylint: disable=protected-access cases = [] for suite in xml: for case in suite: cases.append(case) # or directly <testsuite> (only 1) tag - nose & py.test else: cases = list(xml) for xml_case in cases: summary = "%s.%s" % (xml_case.classname, xml_case.name) test_case = self.backend.test_case_get_or_create(summary) test_case_id = test_case['case_id'] self.backend.add_test_case_to_plan(test_case_id, self.backend.plan_id) test_execution_id = self.backend.add_test_case_to_run( test_case_id, self.backend.run_id) comment = 'Result recorded via Kiwi TCMS junit.xml-plugin' if xml_case.result is None: status_id = self.backend.get_status_id('PASSED') if isinstance(xml_case.result, Failure): status_id = self.backend.get_status_id('FAILED') comment = xml_case.result.tostring() if isinstance(xml_case.result, Error): status_id = self.backend.get_status_id('ERROR') comment = xml_case.result.tostring() if isinstance(xml_case.result, Skipped): status_id = self.backend.get_status_id('WAIVED') comment = xml_case.result.message self.backend.update_test_execution(test_execution_id, status_id, comment) if progress_cb: progress_cb()
class Plugin: # pylint: disable=too-few-public-methods def __init__(self): self.backend = Backend(prefix='[junit.xml]') def parse(self, junit_xml, progress_cb=None): self.backend.configure() xml = JUnitXml.fromfile(junit_xml) # apparently junit.xml may contain either a <testsuites> tag, # e.g. Katalon Studio if xml._tag == "testsuites": # pylint: disable=protected-access cases = [] for suite in xml: for case in suite: cases.append(case) # or directly <testsuite> (only 1) tag - nose & py.test else: cases = list(xml) for xml_case in cases: summary = f"{xml_case.classname}.{xml_case.name}" test_case, _ = self.backend.test_case_get_or_create(summary) self.backend.add_test_case_to_plan(test_case['id'], self.backend.plan_id) comment = 'Result recorded via Kiwi TCMS junit.xml-plugin' if not xml_case.result: status_id = self.backend.get_status_id('PASSED') # note: since junitpartser v2.0 the result attribute holds # a list of values b/c pytest can produce files which contain # multiple results for the same test case. We take the first! for result in xml_case.result: if isinstance(result, Failure): status_id = self.backend.get_status_id('FAILED') comment = result.tostring() break if isinstance(result, Error): status_id = self.backend.get_status_id('ERROR') comment = result.tostring() break if isinstance(result, Skipped): status_id = self.backend.get_status_id('WAIVED') comment = result.message break for execution in self.backend.add_test_case_to_run( test_case['id'], self.backend.run_id, ): self.backend.update_test_execution(execution["id"], status_id, comment) if progress_cb: progress_cb() self.backend.finish_test_run()