Simone Carletti wrote:
> Hello,
> 
> I was reading unit tests from some recent components and I noticed most of
> them include the following statement:
> 
> require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php';
> require_once "PHPUnit/Framework/TestCase.php";
> require_once "PHPUnit/Framework/TestSuite.php";

The latter require_once directives are remnants that may be removed,
since, as you noticed, the TestHelper includes the parts of PHPUnit most
commonly used within the test suites. Also, it is not necessary to call
dirname() multiple times. Just do:

require_once dirname(__FILE__) . '/../../TestHelper.php';

> I was wondering if is there any particular reason for including again
> TestCase.php and TestSuite.php.
> They appears to be already required by TestHelper.
> 
> Additionally, I noticed it's a common practice to include TestHelper only in
> the AllTest.php file (main suite).
> This makes impossibile to run a class specific unit test due to an error
> trying to include Zend/* file not available in include_path.

Indeed, the TestHelper should be require_once'd in any test suite that
may be run independently.

> Let me show you a few examples:
> 
> // the following statement works fine
> phpunit --verbose Zend_Service_Yahoo_AllTests
> 
> // the following statements fail
> //  Failed opening required 'Zend/*' ... 
> phpunit --verbose Zend_Service_Yahoo_OfflineTest
> phpunit --verbose Zend_OpenId_ConsumerTest
> 
> // the following statement fails for the same reason as above
> phpunit --verbose Zend_OpenId_AllTests  

If you would be so kind as to create JIRA issues for these, we can make
sure they don't fall through the cracks, and anyone is more than welcome
to help resolve them. Of course, if you just want to resolve them as you
come across them, as I often do, this would be most welcome, too! :)

Thanks for the report, Simone!

Best regards,
Darby

Reply via email to