Reputation: 259
I am new to unit testing so please bear with me if this is a dumb question.
First of all should my test folder mimic my application folder?
For example:
Application
--Autoloader.php
--Library
----VendorA.php
Tests
--Library
----VendorATest.php
Secondly, I am finding myself writing large inlcude statements to get the relevant files included into my test classes. Is there a better way to do this?
<?php
require_once 'PHPUnit/Autoload.php';
require_once(dirname(dirname(dirname(__DIR__))).'/Application/Library/VendorATest.php');
class Tests_Application_Library_VendorATest extends PHPUnit_Framework_TestCase
{}
Upvotes: 1
Views: 166
Reputation: 36562
That's the standard way to organize tests which works great.
As for autoloading, use an autoloader! :) PHPUnit loads a bootstrap file (bootstrap.php
by default) on startup. There's no need to load PHPUnit's files anymore as it has its own autoloader which it initializes from the startup script. Since it appears that you have an autoloader, set it up in that bootstrap file and point it at your classes under test.
Upvotes: 1