This repository was archived by the owner on Apr 12, 2018. It is now read-only.
This repository was archived by the owner on Apr 12, 2018. It is now read-only.
Testing an exception is not thrown #171
Closed
Description
Here, http://phpunit.de/manual/current/en/writing-tests-for-phpunit.html it says that you can easily test an exception is thrown. But maybe you want to test that an exception is not thrown.
For example, a funcion accepts a number x and must be even. If it is odd raises an InvalidArgumentException.
You might want a a testInvalidArgumentThrowsException with dataprovider [111, 3, 77] as well as testValidArgumentDoesNotThrowException with data provider of [2, 10, 48]
Despite I can test exception with the /** xxx */ comment, I try not thrown via a try/catch.
If there is any way to test "not thrown" I suggest to include in that documentation page. If there is no cleaner way, I also suggest to include it in that documentation.
Metadata
Metadata
Assignees
Labels
No labels