예제 #1
0
def run_suite(workspace, project, full_suite_name):
    ''' a suite '''

    # TO DO implement directory suites

    if not utils.test_suite_exists(workspace, project, full_suite_name):
        sys.exit(
            "ERROR: no test suite named {} exists".format(full_suite_name))
    else:
        # get test case list
        test_case_list = utils.get_suite_test_cases(project,
                                                    full_suite_name)

        # get test data for each test case present in the suite 
        # and append tc/data pairs for each test case and for each data
        # set to execution list.
        # if there is no data for a test case, it is appended with an
        # empty dict
        execution_list = []
        for test_case in test_case_list:
            data_sets = utils.get_test_data(workspace,
                                            project,
                                            test_case)
            if data_sets:
                for data_set in data_sets:
                    execution_list.append((test_case, data_set))
            else:
                execution_list.append((test_case, {}))

    multiprocess_executor(execution_list, 1, suite_name=full_suite_name)
예제 #2
0
파일: base.py 프로젝트: saurabhnemade/golem
    def run(self, test_execution, args):
        test_execution.thread_amount = args.threads
        test_execution.cli_drivers = args.browsers
        test_execution.cli_environments = args.environments
        test_execution.timestamp = args.timestamp
        test_execution.interactive = args.interactive
        # test_execution.minimize = args.minimize

        root_path = test_execution.root_path

        if args.project and args.test_or_suite:

            if not args.project in utils.get_projects(root_path):
                msg = [
                    'Error: the project {0} does not exist'.format(
                        args.project), '', 'Usage:', self._parser.usage, '',
                    'Projects:'
                ]
                for proj in utils.get_projects(root_path):
                    msg.append('  {}'.format(proj))
                raise CommandException('\n'.join(msg))
            else:
                test_execution.project = args.project
                test_execution.settings = settings_manager.get_project_settings(
                    args.project, test_execution.settings)
                if utils.test_suite_exists(root_path, test_execution.project,
                                           args.test_or_suite):
                    test_execution.suite = args.test_or_suite
                    # execute test suite
                    start_execution.run_test_or_suite(
                        root_path,
                        test_execution.project,
                        suite=test_execution.suite)
                elif utils.test_case_exists(root_path, test_execution.project,
                                            args.test_or_suite):
                    test_execution.test = args.test_or_suite
                    # execute test case
                    start_execution.run_test_or_suite(root_path,
                                                      test_execution.project,
                                                      test=test_execution.test)
                else:
                    # test_or_suite does not match any existing suite or test
                    msg = [('Error: the value {0} does not match an existing '
                            'suite or test'.format(args.test_or_suite)), '',
                           'Usage:', self._parser.usage]
                    raise CommandException('\n'.join(msg))

        elif not args.project and not args.test_or_suite and test_execution.interactive:
            from golem.test_runner import interactive
            interactive.interactive(test_execution.settings,
                                    test_execution.cli_drivers)

        elif not args.project:
            msg = ['Usage:', self._parser.usage, '', 'Projects:']
            for proj in utils.get_projects(root_path):
                msg.append('  {}'.format(proj))
            raise CommandException('\n'.join(msg))

        elif args.project and not args.test_or_suite:
            msg = ['Usage: {}'.format(self._parser.usage), '', 'Test Cases:']
            print('\n'.join(msg))
            test_cases = utils.get_test_cases(root_path, args.project)
            utils.display_tree_structure_command_line(
                test_cases['sub_elements'])
            print('\nTest Suites:')
            test_suites = utils.get_suites(root_path, args.project)
            for suite in test_suites['sub_elements']:
                print('  ' + suite['name'])
            raise CommandException()
        else:
            # test_or_suite does not match any existing suite or test
            raise CommandException(
                'Error: the value {0} does not match an existing '
                'suite or test'.format(args.test_or_suite))
예제 #3
0
파일: base.py 프로젝트: FabioRosado/golem
    def run(self, test_execution, args):
        test_execution.thread_amount = args.threads
        test_execution.cli_drivers = args.browsers
        test_execution.cli_environments = args.environments
        test_execution.timestamp = args.timestamp
        test_execution.interactive = args.interactive

        root_path = test_execution.root_path
        if args.project and args.test_or_suite:

            if not args.project in utils.get_projects(root_path):
                msg = ['Error: the project {0} does not exist'.format(args.project),
                       '',
                       'Usage:', self._parser.usage,
                       '',
                       'Projects:']
                for proj in utils.get_projects(root_path):
                    msg.append('  {}'.format(proj))
                raise CommandException('\n'.join(msg))
            else:
                test_execution.project = args.project
                test_execution.settings = settings_manager.get_project_settings(root_path, args.project)
                if utils.test_suite_exists(root_path, test_execution.project,
                                           args.test_or_suite):
                    test_execution.suite = args.test_or_suite
                    # execute test suite
                    start_execution.run_test_or_suite(root_path,
                                                      test_execution.project,
                                                      suite=test_execution.suite)
                elif utils.test_case_exists(root_path, test_execution.project,
                                            args.test_or_suite):
                    test_execution.test = args.test_or_suite
                    # execute test case
                    start_execution.run_test_or_suite(root_path,
                                                      test_execution.project,
                                                      test=test_execution.test)
                else:
                    # test_or_suite does not match any existing suite or test
                    msg = [('Error: the value {0} does not match an existing '
                            'suite or test'.format(args.test_or_suite)),
                            '',
                            'Usage:', self._parser.usage]
                    raise CommandException('\n'.join(msg))

        elif not args.project and not args.test_or_suite and test_execution.interactive:
            from golem.test_runner import interactive
            interactive.interactive(test_execution.settings, test_execution.cli_drivers)

        elif not args.project:
            msg = ['Usage:',
                   self._parser.usage,
                   '',
                   'Projects:']
            for proj in utils.get_projects(root_path):
                msg.append('  {}'.format(proj))
            raise CommandException('\n'.join(msg))

        elif args.project and not args.test_or_suite:
            msg = ['Usage: {}'.format(self._parser.usage),
                   '',
                   'Test Cases:']
            print('\n'.join(msg))
            test_cases = utils.get_test_cases(root_path,
                                              args.project)
            utils.display_tree_structure_command_line(test_cases['sub_elements'])
            print('\nTest Suites:')
            test_suites = utils.get_suites(root_path, args.project)
            for suite in test_suites['sub_elements']:
                print('  ' + suite['name'])
            raise CommandException()
        else:
            # test_or_suite does not match any existing suite or test
            raise CommandException(
                'Error: the value {0} does not match an existing '
                'suite or test'.format(args.test_or_suite))
예제 #4
0
파일: main.py 프로젝트: lucianopuccio/golem
def execute_from_command_line(root_path):

    parser = cli.get_golem_parser()
    args = parser.parse_args()

    # set test_execution values
    test_execution.root_path = root_path
    test_execution.settings = utils.get_global_settings()

    import golem.core
    golem.core.temp = test_execution.settings

    # main action == gui
    if args.main_action == 'gui':
        gui_start.run_gui()
        sys.exit()

    # main action == run
    if args.main_action == 'run':
        if not args.project:
            print 'Usage:', parser.usage, '\n\n', 'Project List:'
            for proj in utils.get_projects(root_path):
                print '> {}'.format(proj)
            sys.exit()
        # check if selected project does not exist
        elif not args.project in utils.get_projects(root_path):
            sys.exit('Error: the project {0} does not exist'
                     .format(test_execution.project))
        else:
            test_execution.project = args.project

            # check if test_or_suite value is present
            if not args.test_or_suite:
                print 'Usage:', parser.usage
                print '\nTest Cases:'
                test_cases = utils.get_test_cases(root_path,
                                                  test_execution.project)
                utils.display_tree_structure_command_line(test_cases)
                print '\nTest Suites:'
                test_suites = utils.get_suites(root_path,
                                               test_execution.project)
                utils.display_tree_structure_command_line(test_suites)
                sys.exit()

            # check if test_or_suite value matches an existing test suite
            elif utils.test_suite_exists(root_path,
                                       test_execution.project,
                                       args.test_or_suite):
                test_execution.suite = args.test_or_suite
                # execute test suite
                test_runner.run_suite(root_path,
                                      test_execution.project,
                                      test_execution.suite)

            # check if test_or_suite value matches an existing test case
            elif utils.test_case_exists(root_path,
                                        test_execution.project,
                                        args.test_or_suite):
                test_execution.test = args.test_or_suite
                # execute test case
                test_runner.run_single_test_case(root_path,
                                                 test_execution.project,
                                                 test_execution.test)
            
            else:
                # test_or_suite does not match any existing suite or test
                sys.exit('Error: the value {0} does not match an existing '
                         'suite or test'
                         .format(args.test_or_suite))

    # main action == startproject
    if args.main_action == 'startproject':
        sys.exit('To be defined')

    # main action == createuser
    if args.main_action == 'createuser':
        sys.exit('To be defined')