Home » Php » php – Set a test timeout duration with PHPUnit

php – Set a test timeout duration with PHPUnit

Posted by: admin July 12, 2020 Leave a comment

Questions:

I have some test cases that can go into an infinite loop upon failure. Is there a built-in way to set a test timeout duration with PHPUnit?

If not, what would be the most unobtrusive way of adding this feature to a test case?

How to&Answers:

Maybe you can use the PerformanceTestCase you can set a setMaxRunningTime() with it for a test.

Answer:

You can use the strict mode to set time limits:

phpunit --strict

or

<phpunit strict="true">

What does PHPUnit Strict mode do?