Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to indicate that a PHPUnit test is expected to fail?

Is it possible to mark a test as "expected to fail" with PHPUnit? This would be useful when performing TDD, and you want to distinguish between genuinely failed tests, and tests that happen to fail because the associated code hasn't been written yet.

like image 640
mjs Avatar asked Oct 12 '10 18:10

mjs


2 Answers

I think in these cases, it's fairly standard to simply mark the test as skipped. Your tests will still run and the suite will pass, but the test runner will alert you of the skipped tests.

http://phpunit.de/manual/current/en/incomplete-and-skipped-tests.html

like image 99
Ryan Chouinard Avatar answered Oct 18 '22 18:10

Ryan Chouinard


The 'correct' method of handling this is to use $this->markTestIncomplete(). This will mark the test as incomplete. It will come back as passed, but it will display the message provided. See http://www.phpunit.de/manual/3.0/en/incomplete-and-skipped-tests.html for more information.

like image 27
Tom B Avatar answered Oct 18 '22 17:10

Tom B