How to use run_suites_from_project method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

test_cmd_run.py

Source:test_cmd_run.py Github

copy

Full Screen

...85 def __init__(self, project_dir="."):86 Project.__init__(self, project_dir)87 def load_suites(self):88 return [load_suite_from_class(SampleSuite)]89def _test_run_suites_from_project(project, cli_args, expected_args):90 with patch("lemoncheesecake.cli.commands.run.run_project") as mocked:91 run_suites_from_project(project, build_cli_args(["run"] + cli_args))92 mocked.assert_called_with(*expected_args)93class ReportingBackendMatcher(Matcher):94 def __init__(self, *expected):95 self.expected = expected96 def match(self, actual):97 return sorted([b.get_name() for b in actual]) == sorted(self.expected)98def test_run_suites_from_project_default():99 project = SampleProject(".")100 _test_run_suites_from_project(101 project, [],102 (project, Any(), Any(), ReportingBackendMatcher("json", "html", "console"),103 osp.join(os.getcwd(), "report"), savingstrategy.save_at_each_failed_test_strategy, False, False, 1)104 )105def test_run_suites_from_project_thread_cli_args():106 _test_run_suites_from_project(107 SampleProject(), ["--threads", "4"],108 (Any(), Any(), Any(), Any(), Any(), Any(), Any(), Any(), 4)109 )110def test_run_suites_from_project_thread_env():111 with env_vars(LCC_THREADS="4"):112 _test_run_suites_from_project(113 SampleProject(), [],114 (Any(), Any(), Any(), Any(), Any(), Any(), Any(), Any(), 4)115 )116def test_run_suites_from_project_thread_cli_args_while_threaded_is_disabled():117 project = SampleProject()118 project.threaded = False119 with pytest.raises(LemoncheesecakeException, match="does not support multi-threading"):120 _test_run_suites_from_project(project, ["--threads", "4"], None)121def test_run_suites_from_project_saving_strategy_cli_args():122 _test_run_suites_from_project(123 SampleProject(), ["--save-report", "at_each_failed_test"],124 (Any(), Any(), Any(), Any(), Any(), savingstrategy.save_at_each_failed_test_strategy, Any(), Any(), Any())125 )126def test_run_suites_from_project_saving_strategy_env():127 with env_vars(LCC_SAVE_REPORT="at_each_failed_test"):128 _test_run_suites_from_project(129 SampleProject(), [],130 (Any(), Any(), Any(), Any(), Any(), savingstrategy.save_at_each_failed_test_strategy, Any(), Any(), Any())131 )132def test_run_suites_from_project_reporting_backends_cli_args():133 _test_run_suites_from_project(134 SampleProject(), ["--reporting", "^console"],135 (Any(), Any(), Any(), ReportingBackendMatcher("json", "html"), Any(), Any(), Any(), Any(), Any())136 )137def test_run_suites_from_project_reporting_backends_env():138 with env_vars(LCC_REPORTING="^console"):139 _test_run_suites_from_project(140 SampleProject(), [],141 (Any(), Any(), Any(), ReportingBackendMatcher("json", "html"), Any(), Any(), Any(), Any(), Any())142 )143def test_run_suites_from_project_custom_attr_default_reporting_backend_names():144 project = SampleProject()145 project.default_reporting_backend_names = ["json", "html"]146 _test_run_suites_from_project(147 project, [],148 (Any(), Any(), Any(), ReportingBackendMatcher("json", "html"), Any(), Any(), Any(), Any(), Any())149 )150def test_run_suites_from_project_force_disabled_set():151 _test_run_suites_from_project(152 SampleProject(), ["--force-disabled"],153 (Any(), Any(), Any(), Any(), Any(), Any(), True, Any(), Any())154 )155def test_run_suites_from_project_stop_on_failure_set():156 _test_run_suites_from_project(157 SampleProject(), ["--stop-on-failure"],158 (Any(), Any(), Any(), Any(), Any(), Any(), Any(), True, Any())159 )160def test_run_suites_from_project_report_dir_through_project(tmpdir):161 report_dir = tmpdir.join("other_report_dir").strpath162 class MyProject(SampleProject):163 def create_report_dir(self):164 return report_dir165 _test_run_suites_from_project(166 MyProject(), [],167 (Any(), Any(), Any(), Any(), report_dir, Any(), Any(), Any(), Any())168 )169def test_run_suites_from_project_report_dir_cli_args(tmpdir):170 report_dir = tmpdir.join("other_report_dir").strpath171 _test_run_suites_from_project(172 SampleProject(), ["--report-dir", report_dir],173 (Any(), Any(), Any(), Any(), report_dir, Any(), Any(), Any(), Any())174 )175def test_run_suites_from_project_report_dir_env(tmpdir):176 report_dir = tmpdir.join("other_report_dir").strpath177 with env_vars(LCC_REPORT_DIR=report_dir):178 _test_run_suites_from_project(179 SampleProject(), [],180 (Any(), Any(), Any(), Any(), report_dir, Any(), Any(), Any(), Any())...

Full Screen

Full Screen

run.py

Source:run.py Github

copy

Full Screen

...68 "Got an unexpected exception while creating report directory:%s" % \69 serialize_current_exception(show_stacktrace=True)70 )71 return report_dir72def run_suites_from_project(project, cli_args):73 # Load suites74 suites = load_suites_from_project(project, make_test_filter(cli_args))75 # Get reporting backends76 reporting_backend_names = get_reporting_backend_names(cli_args, project)77 reporting_backends = get_reporting_backends_for_test_run(project.reporting_backends, reporting_backend_names)78 # Get report save mode79 report_saving_strategy = get_report_saving_strategy(cli_args)80 # Create report dir81 report_dir = create_report_dir(cli_args, project)82 # Get number of threads83 nb_threads = get_nb_threads(cli_args, project)84 # Run tests85 report = run_project(86 project, suites, cli_args, reporting_backends, report_dir, report_saving_strategy,87 cli_args.force_disabled, cli_args.stop_on_failure, nb_threads88 )89 # Return exit code90 if cli_args.exit_error_on_failure:91 return 0 if report.is_successful() else 192 else:93 return 094class RunCommand(Command):95 def get_name(self):96 return "run"97 def get_description(self):98 return "Run the tests"99 def add_cli_args(self, cli_parser):100 try:101 project = load_project()102 default_reporting_backend_names = project.default_reporting_backend_names103 except ProjectNotFound:104 project = None105 default_reporting_backend_names = DEFAULT_REPORTING_BACKENDS106 add_test_filter_cli_args(cli_parser)107 project_group = cli_parser.add_argument_group("Project")108 project_group.add_argument(109 "--project", "-p", required=False,110 help="Project path (default: $LCC_PROJECT or lookup for a project in the directory hierarchy)"111 )112 test_execution_group = cli_parser.add_argument_group("Test execution")113 test_execution_group.add_argument(114 "--force-disabled", action="store_true",115 help="Force the run of disabled tests"116 )117 test_execution_group.add_argument(118 "--exit-error-on-failure", action="store_true",119 help="Exit with non-zero code if there is at least one non-passed test"120 )121 test_execution_group.add_argument(122 "--stop-on-failure", action="store_true",123 help="Stop tests execution on the first non-passed test"124 )125 test_execution_group.add_argument(126 "--threads", type=int, default=None,127 help="Number of threads used to run tests (default: $LCC_THREADS or 1)"128 )129 reporting_group = cli_parser.add_argument_group("Reporting")130 reporting_group.add_argument(131 "--report-dir", "-r", required=False,132 help="Directory where report data will be stored (default: $LCC_REPORT_DIR or 'report' depending on "133 "the project configuration)"134 )135 reporting_group.add_argument(136 "--reporting", nargs="+", default=[],137 help="The list of reporting backends to use (default: %s)" % ", ".join(default_reporting_backend_names)138 )139 reporting_group.add_argument(140 "--save-report", required=False,141 help="At what frequency the reporting backends such as json or xml must save reporting data to disk. "142 "(default: $LCC_SAVE_REPORT or at_each_failed_test, possible values are: "143 "at_end_of_tests, at_each_suite, at_each_test, at_each_failed_test, at_each_log, every_${N}s)"144 )145 if project:146 cli_group = cli_parser.add_argument_group("Project custom arguments")147 project.add_cli_args(cli_group)148 def run_cmd(self, cli_args):...

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