WordPress.org

Make WordPress Core

Changeset 223 in tests


Ignore:
Timestamp:
05/14/2009 05:55:03 PM (9 years ago)
Author:
westi
Message:

Add new -l command line option which will list all the available individual TestCase sets.
Also improved the output received when run from the commandline.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-test.php

    r195 r223  
    11<?php
    22
    3 $opts = getopt('v:t:r:sf');
     3$opts = getopt('v:t:r:sf:l');
    44
    55define('DIR_TESTROOT', realpath(dirname(__FILE__)));
     
    9797$GLOBALS['wpdb'] = $original_wpdb;
    9898
    99 do_action('test_start');
    100 
    101 // hide warnings during testing, since that's the normal WP behaviour
    102 error_reporting(E_ALL ^ E_NOTICE);
    103 // run the tests and print the results
    104 $result = wptest_run_tests($classes, @$opts['t']);
    105 wptest_print_result($result);
    106 
     99if ( isset($opts['l']) ) {
     100    wptest_listall_testcases($classes);
     101} else {
     102    do_action('test_start');
     103   
     104    // hide warnings during testing, since that's the normal WP behaviour
     105    error_reporting(E_ALL ^ E_NOTICE);
     106    // run the tests and print the results
     107    $result = wptest_run_tests($classes, @$opts['t']);
     108    wptest_print_result($result);
     109}
    107110// clean up the database
    108111drop_tables();
  • wp-testlib/base.php

    r216 r223  
    500500}
    501501
     502/**
     503 * Simple function to list out all the test cases for command line interfaces
     504 *
     505 * @param $test_classes The test casses array as returned by wptest_get_all_test_cases()
     506 * @return none
     507 */
     508function wptest_listall_testcases($test_classes) {
     509    echo "\nWordPress Tests available TestCases:\n\n"; 
     510    echo array_reduce($test_classes, create_function('$current, $item','return $current . $item . ", ";'));
     511    echo "\n\nUse -t TestCaseName to run individual test cases\n"; 
     512}
     513
    502514function wptest_run_tests($classes, $classname='') {
    503515    $suite = new PHPUnit_Framework_TestSuite();
     
    508520
    509521    #return PHPUnit::run($suite);
    510     return $suite->run();
     522    $result = new PHPUnit_Framework_TestResult;
     523    require_once('PHPUnit/TextUI/ResultPrinter.php');
     524    $result->addListener(new PHPUnit_TextUI_ResultPrinter(NULL,true,true));
     525    return $suite->run($result);
    511526}
    512527
Note: See TracChangeset for help on using the changeset viewer.