By martin107 on
Change record status:
Draft (View all draft change records)
Project:
Introduced in branch:
8.3.x
Issue links:
Description:
This change records reflects the changes made in
https://www.drupal.org/node/2822837
Regarding test code,
Using @expectedException is not considered good testing practice because you cannot specify where exactly in the test method the exception should be triggered. Background info: https://thephp.cc/news/2016/02/questioning-phpunit-best-practices
In short, tags that once appeared in test methods annotations have been removed and an equivalent code snippets inserted into the method.
For example:
* @expectedException \Drupal\contact\MailHandlerException
* @expectedExceptionMessage Unable to determine message recipient
becomes
$this->setExpectedException(MailHandlerException::class, 'Unable to determine message recipient');
Ideally move this calling function as near as possible to the actual code you want to test, to make it obvious where the exception is expected to be thrown.
Impacts:
Module developers