How to use get_top_steps method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

top.py

Source:top.py Github

copy

Full Screen

...147 (duration / total_duration * 100) if total_duration else 100148 ])149 return sorted(data, key=lambda row: row[-2], reverse=True)150 @staticmethod151 def get_top_steps(report, step_filter):152 steps = list(filter(step_filter, report.all_steps()))153 steps_aggregation = TopSteps._get_steps_aggregation(steps)154 return [TopSteps._format_steps_aggregation(*agg) for agg in steps_aggregation]155 def run_cmd(self, cli_args):156 report_path = get_report_path(cli_args)157 report = load_report(report_path, auto_detect_reporting_backends())158 step_filter = make_step_filter(cli_args)159 print_table(160 "Steps, aggregated and ordered by duration",161 ("Step", "Occ.", "Min.", "Max", "Avg.", "Total", "In %"),162 TopSteps.get_top_steps(report, step_filter)163 )...

Full Screen

Full Screen

test_cmd_top.py

Source:test_cmd_top.py Github

copy

Full Screen

...77def test_top_tests_cmd_test_run_in_progress(report_in_progress_path, cmdout):78 assert main(["top-tests", report_in_progress_path]) == 079 cmdout.dump()80 cmdout.assert_substrs_anywhere(["suite.test_2"])81def test_get_top_steps():82 report = make_report([83 make_suite_result("suite1", tests=[make_test_result(steps=[84 make_step("step1", start_time=0.0, end_time=1.0),85 make_step("step1", start_time=1.0, end_time=3.0),86 ])]),87 make_suite_result("suite2", tests=[make_test_result(steps=[88 make_step("step2", start_time=3.0, end_time=4.0)89 ])]),90 ])91 top_steps = TopSteps.get_top_steps(report, StepFilter())92 assert len(top_steps) == 293 assert top_steps[0][0] == "step1"94 assert top_steps[0][1] == "2"95 assert top_steps[0][2] == "1.000s"96 assert top_steps[0][3] == "2.000s"97 assert top_steps[0][4] == "1.500s"98 assert top_steps[0][5] == "3.000s"99 assert top_steps[0][6] == "75%"100 assert top_steps[1][0] == "step2"101 assert top_steps[1][1] == "1"102 assert top_steps[1][2] == "1.000s"103 assert top_steps[1][3] == "1.000s"104 assert top_steps[1][4] == "1.000s"105 assert top_steps[1][5] == "1.000s"106 assert top_steps[1][6] == "25%"107def test_get_top_steps_with_test_session_setup_and_grep():108 @lcc.fixture(scope="session")109 def fixt():110 lcc.set_step("mystep")111 lcc.log_info("foobar")112 @lcc.suite("suite")113 class suite:114 @lcc.test("test")115 def test(self, fixt):116 pass117 report = run_suite_class(suite, fixtures=[fixt])118 top_steps = TopSteps.get_top_steps(report, StepFilter(grep=re.compile("foobar")))119 assert len(top_steps) == 1120 assert top_steps[0][0] == "mystep"121def test_get_top_steps_filter_on_passed():122 @lcc.suite("suite")123 class suite:124 @lcc.test("test")125 def test(self):126 lcc.set_step("something ok")127 lcc.log_info("info")128 lcc.set_step("something not ok")129 lcc.log_error("error")130 report = run_suite_class(suite)131 top_steps = TopSteps.get_top_steps(report, StepFilter(passed=True))132 assert len(top_steps) == 1133 assert top_steps[0][0] == "something ok"134def test_get_top_steps_filter_on_grep():135 @lcc.suite("suite")136 class suite:137 @lcc.test("test")138 def test(self):139 lcc.set_step("something ok")140 lcc.log_info("info")141 lcc.set_step("something not ok")142 lcc.log_error("error")143 report = run_suite_class(suite)144 top_steps = TopSteps.get_top_steps(report, StepFilter(grep=re.compile("error")))145 assert len(top_steps) == 1146 assert top_steps[0][0] == "something not ok"147def test_top_steps_cmd(tmpdir, cmdout):148 report = make_report([149 make_suite_result("suite1", tests=[150 make_test_result(steps=[make_step("step1", start_time=0.1, end_time=1.0)])151 ])152 ])153 report_path = tmpdir.join("report.json").strpath154 save_report_into_file(report, report_path)155 assert main(["top-steps", report_path]) == 0156 lines = cmdout.get_lines()157 assert "step1" in lines[4]158def test_top_steps_cmd_test_run_in_progress(report_in_progress_path, cmdout):...

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