Replace @expectedException @expectedExceptionMessage with $this->setExpectedException

Created on 28 October 2016, about 8 years ago
Updated 2 March 2023, over 1 year ago

Problem/Motivation

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

Proposed resolution

We should use the method setExpectedException() instead right before the line that triggers the exception (usually right before the last line).

Therefore @martin107 and @vaplas worked on an automated conversion script: https://github.com/martinfrances107/convertExceptions

Remaining tasks

Review patch.

📌 Task
Status

Fixed

Version

8.4 ⚰️

Component
PHPUnit 

Last updated about 7 hours ago

Created by

🇬🇧United Kingdom martin107

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024