Nette Tester 2.2.0 is out

by Miloslav Hůla about a month ago in Tester

I didn't write blog article about releasing the 2.1.0. The main purpose for that release was to drop support for PHP below 7.1. Nobody complained so it looks like as a good step.

New in Tester

The 2.1.0 version brought one small feature. The --coverage-src parameter is repeatable, so you can mark separated directories for coverage report.

The 2.2.0 version brings few minor fixes and mainly two new features.

New Tester\Expect objects allows you to test “random” items in more complex data structures. You can use them in $expected parameter of Assert::equal() and Assert::notEqual() methods. For example, you test a method which creates a new user and returns its attributes as an array:

use Tester\Expect;

Assert::equal([
    'id' => 123,
    'username' => 'milo',
    'password' => Expect::match('%h%'),  # random string, hash, but must match some pattern
    'created_at' => Expect::type(DateTimeImmutable::class),  # check type only, not exact value
], User::create(123, 'milo', 'RandomPaSsWoRd'));

Until now, you had to unset these “random” items before assertion or test array items one by one. The usage of Expect is clearer with less effort to type.

You can read more about Expect in documentation.

The second new feature is support for PCOV. I didn't find what that acronym (or is it a word?) means, but it is an PHP extension especially written to provide code coverage functionality. So it is fast. Now, Tester supports three code coverage engines and question arose about which one to choose when more available. I defined following priority:

  1. PCOV, because it is a specialized tool
  2. PHPDBG SAPI, because I suppose that the code coverage is the only reason to run it
  3. Xdebug

Many thanks to all contributors!


Nette Tester 2.0.0 is out

by Miloslav Hůla about a year ago in Tester

Nette Tester 2 is finally out. I'll describe changes and new features in detail.

Compatibility

New Tester requires PHP in version 5.6 or newer and supports PHP 7.2. Simultaneously, support for HHVM has been dropped. There has been small opinion poll on this topic.

Changes in tests runner

Tester's default interpreter (when called without the -p option) is CLI now. It used to be CGI. You will see notice in console about it.

…more


Changes in Nette Tester 1.7.0

by Miloslav Hůla 3 years ago in Tester

Nette Tester 1.7.0 is out. I'll summarize the changes.

HtmlGenerator, which generates HTML code coverage report, now counts lines from not evaluated files as not covered. The only impact is, that you can see lower percentual coverage in report. Imagine the situation, that you have two source files (same lenght for simplification), but only one of them is loaded by tests. You got 100% coverage before, now you get only 50%.

If you are using TestCase test methods with @dataProvider, data provider method can return Traversable now. As a consequence of this, you can use generator (yield). It is handy for lazy data loading, for example from remote API. Short example:

…more


Changes in Nette Tester 1.6.0

by Miloslav Hůla 3 years ago in Tester

Nette Tester 1.6.0 is out. Let me summarize the changes.

New optional parameter $description has been added to almost all Assert methods. It works as an error message prefix when an assertion fails. It is handy in situations where the error message is not self-describing enough. For example, in a loop with assertion:

foreach ($model->getUsers() as $user) {
    Assert::true($user->isActive(), "User $user->name");
}

…more


Changes in Nette Tester 1.5.0

by Miloslav Hůla 4 years ago in Tester

The Nette Tester 1.5.0 has been released last week. It's a small release and here I bring news.

Compatibility with PHP 7 has been improved. Tester works with PHP 7 well and now it supports Throwable interface. So all PHP 7 exceptions are printed and dumped correctly. No more problems are known, if you hit some, open an issue please.

The test runner (vendor/bin/tester) now prints PHP startup errors. It may disclose problem with PHP extensions loading.

…more