How to use report_in_progress_path method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

report.py

Source:report.py Github

copy

Full Screen

...137@pytest.fixture()138def report_in_progress():139 return make_report_in_progress()140@pytest.fixture()141def report_in_progress_path(tmpdir):142 backend = JsonBackend()143 report_path = os.path.join(tmpdir.strpath, "report.json")144 backend.save_report(report_path, make_report_in_progress())145 return report_path146###147# Assertions helpers for quick report checks148###149def _assert_tests_status(report, status, expected):150 actual = [t.path for t in report.all_tests() if t.status == status]151 assert sorted(actual) == sorted(expected)152def assert_test_statuses(report, passed=(), failed=(), skipped=(), disabled=()):153 _assert_tests_status(report, "passed", passed)154 _assert_tests_status(report, "failed", failed)155 _assert_tests_status(report, "skipped", skipped)...

Full Screen

Full Screen

test_cmd_top.py

Source:test_cmd_top.py Github

copy

Full Screen

1import re2from lemoncheesecake.cli import main3from lemoncheesecake.cli.commands.top import TopSuites, TopTests, TopSteps4from lemoncheesecake.reporting.backends.json_ import save_report_into_file5from lemoncheesecake.filter import ResultFilter, StepFilter6import lemoncheesecake.api as lcc7from helpers.cli import cmdout8from helpers.report import report_in_progress_path9from helpers.runner import run_suite_class10from helpers.report import make_test_result, make_suite_result, make_step, make_report11def test_get_top_suites():12 report = make_report([13 make_suite_result("suite1", tests=[make_test_result("test", start_time=0.0, end_time=1.0)]),14 make_suite_result("suite2", tests=[make_test_result("test", start_time=1.0, end_time=4.0)]),15 ])16 top_suites = TopSuites.get_top_suites(report, ResultFilter())17 assert len(top_suites) == 218 assert top_suites[0][0] == "suite2"19 assert top_suites[0][1] == 120 assert top_suites[0][2] == "3.000s"21 assert top_suites[0][3] == "75%"22 assert top_suites[1][0] == "suite1"23 assert top_suites[1][1] == 124 assert top_suites[1][2] == "1.000s"25 assert top_suites[1][3] == "25%"26def test_get_top_suites_with_suite_setup():27 @lcc.suite("suite")28 class suite:29 def setup_suite(self):30 lcc.log_info("foobar")31 @lcc.test("test")32 def test(self):33 pass34 report = run_suite_class(suite)35 top_suites = TopSuites.get_top_suites(report, ResultFilter(grep=re.compile("foobar")))36 assert len(top_suites) == 137 assert top_suites[0][0] == "suite"38 assert top_suites[0][1] == 039 assert top_suites[0][3] == "100%"40def test_top_suites_cmd(tmpdir, cmdout):41 report = make_report([42 make_suite_result("suite1", tests=[make_test_result("test", start_time=0.1, end_time=1.0)]),43 make_suite_result("suite2", tests=[make_test_result("test", start_time=1.0, end_time=4.0)]),44 ])45 report_path = tmpdir.join("report.json").strpath46 save_report_into_file(report, report_path)47 assert main(["top-suites", report_path]) == 048 lines = cmdout.get_lines()49 assert "suite2" in lines[4]50def test_top_suites_cmd_test_run_in_progress(report_in_progress_path, cmdout):51 assert main(["top-suites", report_in_progress_path]) == 052 cmdout.dump()53 cmdout.assert_substrs_anywhere(["suite"])54def test_get_top_tests():55 report = make_report([56 make_suite_result("suite1", tests=[make_test_result("test", start_time=0.0, end_time=1.0)]),57 make_suite_result("suite2", tests=[make_test_result("test", start_time=1.0, end_time=4.0)]),58 ])59 top_suites = TopTests.get_top_tests(report, ResultFilter())60 assert len(top_suites) == 261 assert top_suites[0][0] == "suite2.test"62 assert top_suites[0][1] == "3.000s"63 assert top_suites[0][2] == "75%"64 assert top_suites[1][0] == "suite1.test"65 assert top_suites[1][1] == "1.000s"66 assert top_suites[1][2] == "25%"67def test_top_tests_cmd(tmpdir, cmdout):68 report = make_report([69 make_suite_result("suite1", tests=[make_test_result("test", start_time=0.1, end_time=1.0)]),70 make_suite_result("suite2", tests=[make_test_result("test", start_time=1.0, end_time=4.0)]),71 ])72 report_path = tmpdir.join("report.json").strpath73 save_report_into_file(report, report_path)74 assert main(["top-tests", report_path]) == 075 lines = cmdout.get_lines()76 assert "suite2.test" in lines[4]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):159 assert main(["top-steps", report_in_progress_path]) == 0160 cmdout.dump()...

Full Screen

Full Screen

test_cmd_report.py

Source:test_cmd_report.py Github

copy

Full Screen

1import os.path as osp2from helpers.runner import run_suite_class3from helpers.cli import assert_run_output, cmdout4from helpers.report import report_in_progress_path5import lemoncheesecake.api as lcc6from lemoncheesecake.cli import main7from lemoncheesecake.reporting.backends.json_ import JsonBackend8@lcc.suite("My suite")9class mysuite:10 @lcc.test("My Test 1")11 def mytest1(self):12 lcc.log_error("failure")13 @lcc.test("My Test 2")14 def mytest2(self):15 pass16@lcc.suite()17class suite_with_debug:18 @lcc.test()19 def test(self):20 lcc.set_step("step 1")21 lcc.log_info("1_info_message")22 lcc.log_debug("1_debug_message")23 lcc.set_step("step 2")24 lcc.log_debug("2_debug_message")25 @lcc.test("My Test 2")26 def mytest2(self):27 pass28def test_report_from_dir(tmpdir, cmdout):29 run_suite_class(mysuite, tmpdir=tmpdir, backends=[JsonBackend()])30 assert main(["report", tmpdir.strpath, "--short"]) == 031 assert_run_output(cmdout, "mysuite", successful_tests=["mytest2"], failed_tests=["mytest1"])32def test_report_from_file(tmpdir, cmdout):33 backend = JsonBackend()34 run_suite_class(mysuite, tmpdir=tmpdir, backends=[backend])35 assert main(["report", osp.join(tmpdir.strpath, backend.get_report_filename()), "--short"]) == 036 assert_run_output(cmdout, "mysuite", successful_tests=["mytest2"], failed_tests=["mytest1"])37def test_report_with_filter(tmpdir, cmdout):38 run_suite_class(mysuite, tmpdir=tmpdir, backends=[JsonBackend()])39 assert main(["report", tmpdir.strpath, "--passed", "--short"]) == 040 assert_run_output(cmdout, "mysuite", successful_tests=["mytest2"])41def test_report_detailed(tmpdir, cmdout):42 run_suite_class(mysuite, tmpdir=tmpdir, backends=[JsonBackend()])43 assert main(["report", tmpdir.strpath]) == 044 cmdout.dump()45 cmdout.assert_substrs_in_line(0, ["My Test 1"])46 cmdout.assert_substrs_in_line(1, ["mysuite.mytest1"])47 cmdout.assert_substrs_in_line(3, ["My Test 1"])48 cmdout.assert_substrs_in_line(5, ["ERROR", "failure"])49 cmdout.assert_substrs_in_line(8, ["My Test 2"])50 cmdout.assert_substrs_in_line(9, ["mysuite.mytest2"])51 cmdout.assert_substrs_in_line(10, ["n/a"])52 cmdout.assert_lines_nb(13)53def test_report_detailed_with_arguments(tmpdir, cmdout):54 run_suite_class(mysuite, tmpdir=tmpdir, backends=[JsonBackend()])55 assert main(["report", tmpdir.strpath, "--explicit", "--max-width=80"]) == 056 cmdout.dump()57 cmdout.assert_substrs_in_line(0, ["FAILED: My Test 1"])58 cmdout.assert_substrs_in_line(1, ["mysuite.mytest1"])59 cmdout.assert_substrs_in_line(3, ["My Test 1"])60 cmdout.assert_substrs_in_line(5, ["ERROR", "failure"])61 cmdout.assert_substrs_in_line(8, ["My Test 2"])62 cmdout.assert_substrs_in_line(9, ["mysuite.mytest2"])63 cmdout.assert_substrs_in_line(10, ["n/a"])64 cmdout.assert_lines_nb(13)65def test_report_detailed_with_filter(tmpdir, cmdout):66 run_suite_class(mysuite, tmpdir=tmpdir, backends=[JsonBackend()])67 assert main(["report", tmpdir.strpath, "--failed"]) == 068 cmdout.dump()69 cmdout.assert_substrs_in_line(0, ["My Test 1"])70 cmdout.assert_substrs_in_line(1, ["mysuite.mytest1"])71 cmdout.assert_substrs_in_line(3, ["My Test 1"])72 cmdout.assert_substrs_in_line(5, ["ERROR", "failure"])73 cmdout.assert_lines_nb(9)74def test_report_detailed_with_filter_grep(tmpdir, cmdout):75 run_suite_class(mysuite, tmpdir=tmpdir, backends=[JsonBackend()])76 assert main(["report", tmpdir.strpath, "--grep", "failure"]) == 077 cmdout.dump()78 cmdout.assert_substrs_in_line(0, ["My Test 1"])79 cmdout.assert_substrs_in_line(1, ["mysuite.mytest1"])80 cmdout.assert_substrs_in_line(3, ["My Test 1"])81 cmdout.assert_substrs_in_line(5, ["ERROR", "failure"])82 cmdout.assert_lines_nb(9)83def test_report_test_run_in_progress(report_in_progress_path, cmdout):84 assert main(["report", report_in_progress_path]) == 085 cmdout.dump()86 cmdout.assert_substrs_anywhere(["suite.test_1"])87 cmdout.assert_substrs_anywhere(["step"])88 cmdout.assert_substrs_anywhere(["message"])89def test_report_without_debug_arg(tmpdir, cmdout):90 run_suite_class(suite_with_debug, tmpdir=tmpdir, backends=[JsonBackend()])91 assert main(["report", tmpdir.strpath]) == 092 cmdout.dump()93 cmdout.assert_substrs_anywhere(["step 1"])94 cmdout.assert_substrs_anywhere(["1_info_message"])95 cmdout.assert_substrs_nowhere(["1_debug_message"])96 cmdout.assert_substrs_nowhere(["step 2"])97 cmdout.assert_substrs_nowhere(["2_debug_message"])98def test_report_with_debug_arg(tmpdir, cmdout):99 run_suite_class(suite_with_debug, tmpdir=tmpdir, backends=[JsonBackend()])100 assert main(["report", tmpdir.strpath, "--debug"]) == 0101 cmdout.dump()102 cmdout.assert_substrs_anywhere(["step 1"])103 cmdout.assert_substrs_anywhere(["1_info_message"])104 cmdout.assert_substrs_anywhere(["1_debug_message"])105 cmdout.assert_substrs_anywhere(["step 2"])...

Full Screen

Full Screen

test_cmd_diff.py

Source:test_cmd_diff.py Github

copy

Full Screen

1from helpers.cli import cmdout2from helpers.report import report_in_progress_path3from helpers.report import make_test_result, make_suite_result, make_report4from lemoncheesecake.cli import main5from lemoncheesecake.reporting.backends.json_ import save_report_into_file6from lemoncheesecake.testtree import flatten_tests7from lemoncheesecake.cli.commands.diff import compute_diff8def check_diff(diff, added=[], removed=[], status_changed=[]):9 assert [t.path for t in diff.added] == added10 assert [t.path for t in diff.removed] == removed11 for test_path, old_status, new_status in status_changed:12 assert test_path in [t.path for t in diff.status_changed[old_status][new_status]]13def test_added_test():14 suite_1 = make_suite_result("mysuite", tests=[make_test_result("mytest1")])15 suite_2 = make_suite_result("mysuite", tests=[make_test_result("mytest1"), make_test_result("mytest2")])16 tests_1 = list(flatten_tests([suite_1]))17 tests_2 = list(flatten_tests([suite_2]))18 diff = compute_diff(tests_1, tests_2)19 check_diff(diff, added=["mysuite.mytest2"])20def test_removed_test():21 suite_1 = make_suite_result("mysuite", tests=[make_test_result("mytest1"), make_test_result("mytest2")])22 suite_2 = make_suite_result("mysuite", tests=[make_test_result("mytest1")])23 tests_1 = list(flatten_tests([suite_1]))24 tests_2 = list(flatten_tests([suite_2]))25 diff = compute_diff(tests_1, tests_2)26 check_diff(diff, removed=["mysuite.mytest2"])27def test_passed_to_failed():28 suite_1 = make_suite_result("mysuite", tests=[make_test_result("mytest1", status="passed")])29 suite_2 = make_suite_result("mysuite", tests=[make_test_result("mytest1", status="failed")])30 tests_1 = list(flatten_tests([suite_1]))31 tests_2 = list(flatten_tests([suite_2]))32 diff = compute_diff(tests_1, tests_2)33 check_diff(diff, status_changed=[["mysuite.mytest1", "passed", "failed"]])34def test_failed_to_passed():35 suite_1 = make_suite_result("mysuite", tests=[make_test_result("mytest1", status="failed")])36 suite_2 = make_suite_result("mysuite", tests=[make_test_result("mytest1", status="passed")])37 tests_1 = list(flatten_tests([suite_1]))38 tests_2 = list(flatten_tests([suite_2]))39 diff = compute_diff(tests_1, tests_2)40 check_diff(diff, status_changed=[["mysuite.mytest1", "failed", "passed"]])41def _split_lines(lines, separator):42 group = []43 for line in lines:44 if line == separator:45 if len(group) > 0:46 yield group47 group = []48 else:49 group.append(line)50def test_diff_cmd(tmpdir, cmdout):51 old_report = make_report([52 make_suite_result("mysuite", tests=[53 make_test_result("mytest1"),54 make_test_result("mytest2", status="failed"),55 make_test_result("mytest3")56 ])57 ])58 old_report_path = tmpdir.join("old_report.json").strpath59 save_report_into_file(old_report, old_report_path)60 new_report = make_report([61 make_suite_result("mysuite", tests=[62 make_test_result("mytest1", status="failed"),63 make_test_result("mytest2"),64 make_test_result("mytest4")65 ])66 ])67 new_report_path = tmpdir.join("new_report.json").strpath68 save_report_into_file(new_report, new_report_path)69 assert main(["diff", old_report_path, new_report_path]) == 070 lines = cmdout.get_lines()71 splitted = _split_lines(lines, "")72 added = next(splitted)73 removed = next(splitted)74 status_changed = next(splitted)75 assert "mysuite.mytest4" in added[1]76 assert "mysuite.mytest3" in removed[1]77 assert "mysuite.mytest2" in status_changed[1]78 assert "mysuite.mytest1" in status_changed[2]79def test_diff_cmd_test_run_in_progress(report_in_progress_path, cmdout):80 assert main(["diff", report_in_progress_path, report_in_progress_path]) == 0...

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