def __get_func_tree(self): tree = ResultsTree() tree.add_sample( FunctionalSample(test_case="case1", test_suite="TestClass", status="PASSED", start_time=time.time(), duration=0.12, error_msg=None, error_trace=None, extras=None, subsamples=[])) tree.add_sample( FunctionalSample(test_case="case2", test_suite="TestClass", status="FAILED", start_time=time.time(), duration=0.33, error_msg="something broke", error_trace="stacktrace2", extras=None, subsamples=[])) tree.add_sample( FunctionalSample(test_case="case3", test_suite="TestClass", status="BROKEN", start_time=time.time(), duration=0.33, error_msg="something is badly broken", error_trace="stacktrace3", extras=None, subsamples=[])) return tree, tree
def extract_samples_from_group(group, group_summary): group_name = group_summary.get("name") or "Tests" for sample in group["samples"]: status = "PASSED" if sample["error"]: status = "FAILED" error_msg = "" error_trace = "" assertions = sample.get("assertions") if assertions: for assertion in assertions: if assertion.get("isFailed"): error_msg = assertion.get("errorMessage") status = "BROKEN" rtm = sample.get("responseTime") or 0.0 yield FunctionalSample( test_case=sample["label"], test_suite=group_name, status=status, start_time=int(sample["created"]), duration=rtm / 1000.0, error_msg=error_msg, error_trace=error_trace, extras={}, subsamples=[], )
def read(self, last_pass=False): for row in self.report_reader.read(last_pass): self.read_records += 1 sample = FunctionalSample(test_case=row["test_case"], test_suite=row["test_suite"], status=row["status"], start_time=row["start_time"], duration=row["duration"], error_msg=row["error_msg"], error_trace=row["error_trace"], extras=row.get("extras", {})) yield sample
def get_reader(self): mock = MockFunctionalReader() mock.data = [ FunctionalSample(test_case="test1", test_suite="Tests1", status="PASSED", start_time=1, duration=1, error_msg=None, error_trace=None, extras=None, subsamples=[]), FunctionalSample(test_case="test2", test_suite="Tests1", status="BROKEN", start_time=2, duration=1, error_msg="Something broke", error_trace=None, extras=None, subsamples=[]), FunctionalSample(test_case="test3", test_suite="Tests2", status="PASSED", start_time=2, duration=1, error_msg=None, error_trace=None, extras=None, subsamples=[]), FunctionalSample(test_case="test2", test_suite="Tests1", status="FAILED", start_time=3, duration=1, error_msg="Something failed", error_trace=None, extras=None, subsamples=[]), FunctionalSample(test_case="test1", test_suite="Tests1", status="SKIPPED", start_time=3, duration=1, error_msg="Disabled by user", error_trace=None, extras=None, subsamples=[]), FunctionalSample(test_case="test3", test_suite="Tests2", status="PASSED", start_time=4, duration=1, error_msg=None, error_trace=None, extras=None, subsamples=[]), FunctionalSample(test_case="test1", test_suite="Tests1", status="BROKEN", start_time=4, duration=1, error_msg="Broken", error_trace=None, extras=None, subsamples=[]), FunctionalSample(test_case="test1", test_suite="Tests1", status="PASSED", start_time=5, duration=1, error_msg=None, error_trace=None, extras=None, subsamples=[]), FunctionalSample(test_case="test2", test_suite="Tests1", status="PASSED", start_time=4, duration=1, error_msg=None, error_trace=None, extras=None, subsamples=[]), FunctionalSample(test_case="test3", test_suite="Tests2", status="FAILED", start_time=6, duration=1, error_msg="Really failed", error_trace=None, extras=None, subsamples=[]), FunctionalSample(test_case="test1", test_suite="Tests1", status="PASSED", start_time=6, duration=1, error_msg=None, error_trace=None, extras=None, subsamples=[]), ] return mock