PHPUnit 4 released

A few days ago Sebastian Bergmann released version  4.0.0 of PHPUnit. I was expecting more new features due to this major version, but it did not happened. I will describe some of my favourite changes in this new version.

– Implemented #813: Added @before, @after, @beforeClass and @afterClass annotations.

The @after annotation can be used to specify methods that should be called after each test method in a test case class.

The @afterClass annotation can be used to specify static methods that should be called after all test methods in a test class have been run to clean up shared fixtures.

– Implemented #834: Added the @requires OS annotation. ( A regexp matching PHP_OS )

Some considerations before migrating version:

– A test will now fail in strict mode when it uses the @covers annotation and code that is not expected to be covered is executed.

– All relative paths in a configuration file are now resolved relative to that configuration file. When upgrading, you may need to update relative paths for the following configurations: testSuiteLoaderFile, printerFile, testsuites/file, testsuites/exclude.

Changes in PHPUnit_MockObject:

– A more useful error message is now displayed when the stubbing or mocking of a method fails because a class or interface that is used in the method’s signature is not loaded.
– Implemented #108: Improved error reporting when invocation parameters don’t match.

Changes in PHP_CodeCoverage:

– Migrated the HTML report from Bootstrap 2.3 to Bootstrap 3