For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > May 2006 > Re: [PEAR] [PHPUnit]: Directory structure for unit tests









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PEAR] [PHPUnit]: Directory structure for unit tests
Stefano F. Rausch

2006-05-29, 7:02 pm

Hi Andreas,

It's a matter of taste.

However, if you are using PHPUnit2, see the structure that's defined there, which, BTW, I would suggest very strongly to follow. I.e.:

<project root>
|
+ ClassA.php
+ ClassB.php
|
+ <subpackage>
| |
| + ClassC.php
| + ClassD.php
|
+ <Tests>
|
+ AllTests.php (includes: <subpackage>/AllTests.php)
+ ClassATest.php
+ ClassBTest.php
|
+ <subpackage>
|
+ AllTests.php
+ ClassCTest.php
+ ClassDTest.php

With this structure, you can independently tests every single class, every "subpackage" or all classes together. Furthermore you can deploy the production code without the tests - if you really don't want to do it ;)

HTH

-- Stefano

Andreas Hofmann wrote:
>
> Hi all,
>
> I am new to PHP and I wonder how unit tests (PHPUnit2) should be
> structured in directories within a PHP project?
>
> Is it:
> a)
> <project root>
> |
> |- a.php
> |- b.php
> |-<test>
> | aTest.php
> | bTest.php
> |-<package>
> |
> | c.php
> |-<test>
> |-cTest.php
>
> b)
> <project root>
> |
> |- a.php
> |- b.php
> |- aTest.php
> |- bTest.php
> |-<package>
> |
> | c.php
> |-cTest.php
>
> c)
> <project root>
> |
> |- a.php
> |- b.php
> |-<package>
> | |
> | | c.php
> |-<test>
> |- aTest.php
> |- bTest.php
> |- cTest.php
>
> Or is it something completly different, or doesn't it matter?
>
> Thanks in advance
> Andreas
>
> --
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com