Running PHPUnit Tests from a Custom Infrastructure Directory

For our project, I created a framework on top of the PHPUnit framework that helps us with some common tasks when writing unit tests.

This custom structure inherits from PHPUnit_Framework_TestCase , and then modifies mySetup () and adds a bunch of useful functions to our code.

<?php

class OurUnitTestFramework extends PHPUnit_Framework_TestCase {

    public $dbMock;
    protected function mySetup (..) { ... }
    protected function testHelper () { ... }

}
?>

Now in our test code, we simply expand our work program, and then write tests.

<?php 
require_once ("OurUnitTestFramework");
class DatabaseConnectionTest extends OurUnitTestFramework {
     parent::setUp (..) { ... }
     public function testSomeThing () { ... }
     public function testSomeOtherThing () { ... }

}
?>

So far, we have performed all unit tests through Jenkins, and it still works fine, but now when we try to run the tests in the folder, it fails. All tests inside the folder / subfolder succeed, but there is one failure:

[sumit@dev model]$ phpunit database
PHPUnit 3.5.14 by Sebastian Bergmann.

F........

Time: 0 seconds, Memory: 10.50Mb

There was 1 failure:

1) Warning
No tests found in class "OurUnitTestFramework".


FAILURES!
Tests: 9, Assertions: 30, Failures: 1.

, , , OurUnitTestFramework, , . , phpunit , / ?

, , , -, , .

+3
1

"OurUnitTestFramework" .

+4

All Articles