Idea
In Nette components test suits is quite common to use a test() function:
test(function () {
Assert::...()
Assert::...()
Assert::...()
});
Sometimes, I'm using it too and I would like to make it official & supported. Plus add possibility to name such blocks of assertions. For example:
Assert::block('Invariability', function () {
Assert::...()
Assert::...()
Assert::...()
});
The description of block will be shown in stack trace, e.g.:
-- FAILED: tests\RunnerOutput\JUnitPrinter.phpt
Invariability
Exited with error code 255 (expected 0)
E_NOTICE: Undefined property: .....
in src\Framework\Dumper.php(265)
in src\Framework\Environment.php(127) Tester\Dumper::dumpException()
It should be nested, it can be used for testMethods(), it could solve the #293, related to #133.
Actually, it emulates TestCase methods stack trace a little bit.
Implementation
public static function block($name, \Closure $cb)
{
try {
$cb();
} catch (\Exception $e) {
throw new AssertBlockException($name, $e);
}
}
Idea
In Nette components test suits is quite common to use a
test()function:Sometimes, I'm using it too and I would like to make it official & supported. Plus add possibility to name such blocks of assertions. For example:
The description of block will be shown in stack trace, e.g.:
It should be nested, it can be used for testMethods(), it could solve the #293, related to #133.
Actually, it emulates
TestCasemethods stack trace a little bit.Implementation