What does PHPUnit Strict mode do?

前端 未结 2 1498
温柔的废话
温柔的废话 2020-12-28 12:42

I am wondering about what \"strict mode is in PHPUnit\" ?

eg:

phpunit --strict

or in phpunit.xml



        
2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-28 13:33

    Please note that PHPUnit swallows all output that is emitted during the execution of a test. In strict mode, a test that emits output will fail.

    That's all I could find in documentation, but I'd also checked the sources and I found that in strict mode:

    1. Tests with no assertions might be marked as incomplete/failures.
    2. Each test might be run with execution time limit depending on it's size and the presence of the pcntl extension and PHP_Invoker library. There are three timeouts values:

      • timeoutForSmallTests (default value: 1)
      • timeoutForMediumTests (default value: 10)
      • timeoutForLargeTests (default value: 60)

      The test size (small, medium or large) is determined by the PHPUnit_Util_Test::getSize() method:

      • Test cases descending from PHPUnit_Extensions_Database_TestCase or PHPUnit_Extensions_SeleniumTestCase are large.
      • Test cases and individual tests can also be made large or medium by adding them to the 'large' or 'medum' groups, respectively.
      • Otherwise, the test is small.

    It's seems that strict mode does only the above three changes, but I'm not absolutely sure about that. I have never studied PHPUnit's sources before, nor used strict mode.

提交回复
热议问题