Skip to content

Commit

Permalink
Refitting test reporter as progress reporter.
Browse files Browse the repository at this point in the history
As in the orginal concept as of `Unit::_result()`.
This will allow to progress print after each assertion.
  • Loading branch information
mariuswilms committed May 23, 2012
1 parent 65eddeb commit 266559b
Show file tree
Hide file tree
Showing 21 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions test/Dispatcher.php
Expand Up @@ -40,8 +40,8 @@ class Dispatcher extends \lithium\core\StaticObject {
* - `'case'`: The fully namespaced test case to be run. * - `'case'`: The fully namespaced test case to be run.
* - `'group'`: The fully namespaced test group to be run. * - `'group'`: The fully namespaced test group to be run.
* - `'filters'`: An array of filters that the test output should be run through. * - `'filters'`: An array of filters that the test output should be run through.
* - `'reporter'`: The reporter to use, defaults to `'console'`. * - `'format'`: The format of the template to use, defaults to `'txt'`.
* - `'format'`: The format of the reporter template to use, defaults to `'txt'`. * - `'reporter'`: The reporter to use.
* @return array A compact array of the title, an array of the results, as well * @return array A compact array of the title, an array of the results, as well
* as an additional array of the results after the $options['filters'] * as an additional array of the results after the $options['filters']
* have been applied. * have been applied.
Expand All @@ -51,8 +51,8 @@ public static function run($group = null, array $options = array()) {
$defaults = array( $defaults = array(
'title' => $group, 'title' => $group,
'filters' => array(), 'filters' => array(),
'reporter' => 'console',
'format' => 'txt', 'format' => 'txt',
'reporter' => null,
'progress' => null 'progress' => null
); );
$options += $defaults; $options += $defaults;
Expand Down
19 changes: 10 additions & 9 deletions test/Report.php
Expand Up @@ -17,18 +17,17 @@
* obtain the results and stats (passes, fails, exceptions, skips) of the test run. * obtain the results and stats (passes, fails, exceptions, skips) of the test run.
* *
* While Lithium already comes with a text-based as well as web-based test interface, you * While Lithium already comes with a text-based as well as web-based test interface, you
* may use or extend the `Report` class to create your own test reporter functionality. In * may use or extend the `Report` class to create your own test report functionality. In
* addition, you can also create your own custom templates for displaying results in a different * addition, you can also create your own custom templates for displaying results in a different
* format, such as json. * format, such as json.
* *
* Example usage, for built-in HTML format/reporter: * Example usage, for built-in HTML format:
* *
* {{{ * {{{
* $report = new Report(array( * $report = new Report(array(
* 'title' => 'Test Report Title', * 'title' => 'Test Report Title',
* 'group' => new Group(array('data' => array('lithium\tests\cases\net\http\MediaTest'))), * 'group' => new Group(array('data' => array('lithium\tests\cases\net\http\MediaTest'))),
* 'format' => 'html', * 'format' => 'html'
* 'reporter' => 'html'
* )); * ));
* *
* $report->run(); * $report->run();
Expand Down Expand Up @@ -105,16 +104,16 @@ class Report extends \lithium\core\Object {
* @param array $config Options array for the test run. Valid options are: * @param array $config Options array for the test run. Valid options are:
* - `'group'`: The test group with items to be run. * - `'group'`: The test group with items to be run.
* - `'filters'`: An array of filters that the test output should be run through. * - `'filters'`: An array of filters that the test output should be run through.
* - `'reporter'`: The reporter to use, defaults to `'console'`. * - `'format'`: The format of the template to use, defaults to `'txt'`.
* - `'format'`: The format of the reporter template to use, defaults to `'txt'`. * - `'reporter'`: The reporter to use.
*/ */
public function __construct(array $config = array()) { public function __construct(array $config = array()) {
$defaults = array( $defaults = array(
'title' => null, 'title' => null,
'group' => null, 'group' => null,
'filters' => array(), 'filters' => array(),
'reporter' => 'console',
'format' => 'txt', 'format' => 'txt',
'reporter' => null,
'progress' => null 'progress' => null
); );
parent::__construct($config + $defaults); parent::__construct($config + $defaults);
Expand Down Expand Up @@ -146,7 +145,9 @@ public function run() {
$this->results['filters'][$filter] = array(); $this->results['filters'][$filter] = array();
$tests = $filter::apply($this, $tests, $options['apply']) ?: $tests; $tests = $filter::apply($this, $tests, $options['apply']) ?: $tests;
} }
$this->results['group'] = $tests->run(); $this->results['group'] = $tests->run(array(
'reporter' => $this->_config['reporter']
));


foreach ($this->filters() as $filter => $options) { foreach ($this->filters() as $filter => $options) {
$this->results['filters'][$filter] = $filter::analyze($this, $options['analyze']); $this->results['filters'][$filter] = $filter::analyze($this, $options['analyze']);
Expand Down Expand Up @@ -228,7 +229,7 @@ public function render($template, $data = array()) {
if ($template == "stats" && !$data) { if ($template == "stats" && !$data) {
$data = $this->stats(); $data = $this->stats();
} }
$template = Libraries::locate("test.templates.{$config['reporter']}", $template, array( $template = Libraries::locate('test.templates', $template, array(
'filter' => false, 'type' => 'file', 'suffix' => ".{$config['format']}.php" 'filter' => false, 'type' => 'file', 'suffix' => ".{$config['format']}.php"
)); ));
$params = compact('template', 'data', 'config'); $params = compact('template', 'data', 'config');
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 266559b

Please sign in to comment.