PHP Класс lithium\test\Report
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
addition, you can also create your own custom templates for displaying results in a different
format, such as json.
Example usage, for built-in HTML format/reporter:
{{{
$report = new Report(array(
'title' => 'Test Report Title',
'group' => new Group(array('data' => array('\lithium\tests\cases\net\http\MediaTest'))),
'format' => 'html',
'reporter' => 'html'
));
$report->run();
Get the test stats:
$report->stats();
Get test results:
$report->results
}}}
You may also choose to filter the results of the test runs to obtain additional information.
For example, say you wish to calculate the cyclomatic complexity of the classes you are testing:
{{{
$report = new Report(array(
'title' => 'Test Report Title',
'group' => new Group(array('data' => array('\lithium\tests\cases\net\http\MediaTest'))),
'filters' => array('Complexity')
));
$report->run();
Get test results, including filter results:
$report->results
}}}
Показать файл
Открыть проект
Примеры использования класса
Открытые свойства
Свойство |
Тип |
Описание |
|
$group |
object |
Contains an instance of lithium\test\Group, which contains all unit tests to be executed
this test run. |
|
$results |
array |
Group and filter results. |
|
$timer |
array |
Start and end timers. |
|
$title |
string |
Title of the group being run. |
|
Защищенные свойства (Protected)
Свойство |
Тип |
Описание |
|
$_filters |
array |
An array key on fully-namespaced class names of the filter with options to be
applied for the filter as the value |
|
Открытые методы
Защищенные методы
Описание методов
__construct()
публичный Метод
public __construct ( array $config = [] ) : void |
$config |
array |
Options array for the test run. Valid options are:
- `'group'`: The test group with items to be run.
- `'filters'`: An array of filters that the test output should be run through.
- `'format'`: The format of the template to use, defaults to `'txt'`.
- `'reporter'`: The reporter to use. |
Результат |
void |
|
collect()
публичный Метод
Collects Results from the test filters and aggregates them.
public collect ( string $class, array $results ) : void |
$class |
string |
Classname of the filter for which to aggregate results. |
$results |
array |
Array of the filter results for
later analysis by the filter itself. |
Результат |
void |
|
filters()
публичный Метод
Renders the test output (e.g. layouts and filter templates).
Return statistics from the test runs.
Описание свойств
$_filters защищенное свойство
An array key on fully-namespaced class names of the filter with options to be
applied for the filter as the value
protected array $_filters |
Результат |
array |
|
$group публичное свойство
Contains an instance of lithium\test\Group, which contains all unit tests to be executed
this test run.
public object $group |
Результат |
object |
|
$results публичное свойство
Group and filter results.
public array $results |
Результат |
array |
|
$timer публичное свойство
public array $timer |
Результат |
array |
|
$title публичное свойство
Title of the group being run.
public string $title |
Результат |
string |
|