Quantcast
Viewing all articles
Browse latest Browse all 294808

Replace @expectedException @expectedExceptionMessage with $this->setExpectedException

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.


Viewing all articles
Browse latest Browse all 294808

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>