0
votes

I have a test suite which has about 50 tests - each of which is testing an async network call implemented via promises. When I run PHPUnit, it executes all tests and all of them pass - everytime.

But when i use coverage, all of the tests dont run, the first test runs partially and the script exits, with no coverage generated. Any help?

This is my command:

phpunit --coverage-html ./coverage --debug --verbose tests/

My code is something like this:

class ClassToTest
{
  function foo($callback)
  {
    //asynchronously do something, trigger callback when done.
  }
}

class Test
{
  function testFoo()
  {
    $count = 1;
    $obj->foo( new function() {
      $obj->foo( new function() {
        $obj->foo( new function() {
          $count = 0;
        });
      });
    });
    // check if $count == 0, exit. If not, then sleep for sometime and repeat.
  }
}

I am using PHP 5.6.6

I tried running the same thing with PHPStorm, and I finally got an error code in its console. This is what it says:

Process finished with exit code -1073740940 (0xC0000374)

Found no support for this error. Any help appreciated. Thanks.

2
Can we see an example of your test code? - Cryptographic_ICE
Is this something related to timeout? I notice this is happening for long running tests only. But PHPUnit gives no error. It just silently completes running. I raised the max_execution_time = 7200 in php.ini. But it is not helping. Maybe another PHPUnit specific time limit is being imposed? - Bonton255
you could try explicitly running a test with something like phpunit --coverage-html ./coverage --debug --verbose tests/name_of_test.php or you could move all other tests out of the directory. that would tell us if it is realated to a specifc test. Do you have a phpunit.xml file for config? - Cryptographic_ICE
Yes, i tried that. It is happening for few tests. I figured out that this failure happens only when executing long running tests. The shorter tests run fine and generate the report. But the tests running longer than 20-30 seconds, the script crashes. - Bonton255

2 Answers

0
votes

If strict mode is enabled you may need to annotate your tests

class MyTest extends PHPUnit_Framework_TestCase {
    /**
     * @large
     */
    public function testSomething(){
        // some test code here;
    }
}
-2
votes

If anyone else is facing this problem: I managed to successfully run all the tests on a linux machine.