Nette Tester 2.4.0 is out

3 years ago by Miloslav Hůla  

A new smaller release is out. And since there are no posts on the blog about the patches from 2.3.1 to 2.3.5, I will address them in this post too. Let's move from the past to the present.

Patch releases

Version 2.3.1 is purely maintenance release, just like version 2.3.2, but this release brought two small improvements.

The first is that Tester\Runner has a new public property string[] $ignoreDirs. It contains directories that are ignored by the runner when searching for test files. The default one is vendor.

The second is that Tester\DomQuery does not issue a warning when parsing an “unknown” HTML tag, because it is quite hard to tell what is “unknown”. With this change, HTML can contain SVG or MathML tags, or any custom element at all.

Tester internally started to use GitHub Actions workflow and PHPStan.

Version 2.3.3 brought other minor improvements.

If the Dumper's output contains any paths, they can now be clicked in the PhpStorm terminal with the Awesome Console plugin.

Waiting for the last runner job has been fixed. The bug was causing high CPU usage.

The assertion exception message contains @dataProvider dataset name (array key). With a large number of datasets, it was quite difficult to detect the wrong one. Now you get a hint, e.g.: true should be false in testMe() (data set '231').

The distribution of the PHAR tester has been dropped. I found that tester.phar didn't work for a really long time and nobody complained. The dead code was buried.

Version 2.3.4 is another maintenance release. It was released when PHP 8.0 RC was being born, and contains revisions for incoming PHP 8 compatibility.

Version 2.3.5 is a bug fixing release and compatibility improvement. It primarily supports Xdebug 3. And one annoying processing bug @dataProvider has been fixed. If you use integer-indexed datasets, it may happen that only the first record of the dataset was tested. So please update.

Version 2.4.0

And finally, version 2.4.0 is a fresh new minor version.

The code coverage report got a few improvements thanks to Matouš Němec (mesour). Loading in the browser is about an order of magnitude faster and the generated file size is about 20% smaller. The list of test files can be sorted by coverage percentage or by name and arranged in a tree. The report name contains information about the number of files and lines of code. See example. Thanks to Matouš!

In Tester\Assert there are new methods hasKey() and hasNotKey() that test for the presence of a key in an array.

In Tester\Runner\Test there is a new method getDuration(): ?float that returns the run time in seconds. Null means that the test did not run, for example it was skipped during initialization. You can use the duration information in your own output handlers.

The command line option -o is repeatable and accepts a filename parameter. If the filename is omitted, stdout is used. See example:

tester -o console -o log:report.log -o junit:report.xml

Option --log is replaced by option -o log, but still works to maintain compatibility.

The test handler now uses a cache for the list of test case methods. What does this mean? If you write tests as TestCase, the runner must examine the test method list each time it runs. With a large number of TestCases, say 100, this could take 2 seconds or more due to the number of PHP processes. This delay is now omitted. The test handler keeps track of the modification time of the test case class file, its parent and all its traits. As a storage it uses temporary directory configurable with the --temp option. Please send me feedback on this feature.

The Tester\TestCase has a new method skip(string $message). With it you can skip an individual test method, not the whole test suite.

And one small BC break. Method DataProvider::load() can now return an empty data set. Previously it threw an exception in this case, so your existing tests should not be affected.

And that's it. See you next time.