Example #1
0
def run_integration_tests(opts=None):
    '''
    Execute the integration tests suite
    '''
    if not opts:
        opts = {}
    print('~' * PNUM)
    print('Setting up Salt daemons to execute tests')
    print('~' * PNUM)
    with TestDaemon():
        if opts.get('module', True):
            moduleloader = saltunittest.TestLoader()
            moduletests = moduleloader.discover(
                os.path.join(TEST_DIR, 'integration', 'modules'), '*.py')
            print('~' * PNUM)
            print('Starting Module Tests')
            print('~' * PNUM)
            saltunittest.TextTestRunner(verbosity=1).run(moduletests)
        if opts.get('client', True):
            clientloader = saltunittest.TestLoader()
            clienttests = clientloader.discover(
                os.path.join(TEST_DIR, 'integration', 'client'), '*.py')
            print('~' * PNUM)
            print('Starting Client Tests')
            print('~' * PNUM)
            saltunittest.TextTestRunner(verbosity=1).run(clienttests)
        if opts.get('shell', True):
            shellloader = saltunittest.TestLoader()
            shelltests = shellloader.discover(
                os.path.join(TEST_DIR, 'integration', 'shell'), '*.py')
            print('~' * PNUM)
            print('Starting Shell Tests')
            print('~' * PNUM)
            saltunittest.TextTestRunner(verbosity=1).run(shelltests)
Example #2
0
def run_unit_tests(opts=None):
    '''
    Execute the unit tests
    '''
    if not opts:
        opts = {}
    if not opts.get('unit', True):
        return
    loader = saltunittest.TestLoader()
    tests = loader.discover(os.path.join(TEST_DIR, 'unit', 'templates'),
                            '*.py')
    print('~' * PNUM)
    print('Starting Unit Tests')
    print('~' * PNUM)
    saltunittest.TextTestRunner(verbosity=1).run(tests)
Example #3
0
def run_suite(opts, path, display_name, suffix='[!_]*.py'):
    '''
    Execute a unit test suite
    '''
    loader = saltunittest.TestLoader()
    if opts.name:
        tests = loader.loadTestsFromName(opts.name)
    else:
        tests = loader.discover(path, suffix, TEST_DIR)
    print('~' * PNUM)
    print('Starting {0} Tests'.format(display_name))
    print('~' * PNUM)
    if opts.xmlout:
        runner = xmlrunner.XMLTestRunner(output='test-reports').run(tests)
    else:
        runner = saltunittest.TextTestRunner(
            verbosity=opts.verbosity).run(tests)
    return runner.wasSuccessful()
Example #4
0
def run_suite(opts, path, display_name, suffix='[!_]*.py'):
    '''
    Execute a unit test suite
    '''
    loader = saltunittest.TestLoader()
    if opts.name:
        tests = loader.loadTestsFromName(display_name)
    else:
        tests = loader.discover(path, suffix, TEST_DIR)

    header = '{0} Tests'.format(display_name)
    print_header('Starting {0}'.format(header))

    if opts.xmlout:
        runner = xmlrunner.XMLTestRunner(output=XML_OUTPUT_DIR).run(tests)
    else:
        if not os.path.isdir(XML_OUTPUT_DIR):
            os.makedirs(XML_OUTPUT_DIR)
        runner = saltunittest.TextTestRunner(
            verbosity=opts.verbosity).run(tests)
        TEST_RESULTS.append((header, runner))

    return runner.wasSuccessful()