elfstack/ unit-test-lite
一个轻量级的单元测试类,提供基本的测试功能和美观的报告。
v0.1.3
2016-08-25 08:59 UTC
This package is auto-updated.
Last update: 2024-09-17 09:48:42 UTC
README
ElfStack\Unit是一个易于使用的单元测试类,功能不多但轻便易用。
快速概述
让我们看看一个代码示例
use ElfStack\Unit;
$unit = new Unit();
$unit->start('Unit test group name(can be null)');
$str = 'Hello World!';
$unit->describe('First way to use', 'Here comes more info')->expect($str)->toBe('Hello World');
$unit->describe('Simple compare', 'You can also use not to be')->expect($str)->notToBe(null);
$unit->assertEqual('You can also use this way to run a test', $str, 'Hello World!', 'More info comes here now');
$unit->assertUnequal('Unequal method', $str, null);
$unit->assert('You can use user defined functions too.', function () use ($str) {
echo 'Output in function will shows too.';
return $str == true;
}, 'Any function call be recognized by `is_callable` can be called.<br>The function\'s output and return value are displayed as `Expected` and `Got`.');
$unit->printResult();
$unit->start();
$var = 1 + 1;
$unit->assertEqual('You can use `start` method to start another group of unit test.', $var, 2,
'You can print result in one page too.<br>You can use `result` method to get result without output it.');
echo $unit->result();
并且你会得到(显示为67%)
用法
composer require elfstack/unit-test-light