views:

35

answers:

3

I have a php project in subversion, with the typical /project/trunk/, /project/test/, /project/branches/ structure. I want to start writing some unit tests with PHPUnit. Where is a good place to store these files in version control?

If I put them in /project/unittests/, I would have to check out the directory they test in parallel, so that's a little hassle that I have to make sure I do properly. If I keep them in the project, say at /project/trunk/unittests/, then they will be there when I deploy the site, unless I have some extra hooks not to export them, or at least make sure my .htaccess doesn't allow serving them.

+1  A: 

You can put them anywhere. Personally I always setup my project like this:

 project
   |-- trunk/
   |     |-- ... Other directory
   |     `-- tests
   |-- branches
   |     `-- development
   `-- tags

When I merge the trunk to the development branch, I don't commit the "trunk/tests" directory.

That way, any tag created using the development branch do not include the tests.

yvoyer
+3  A: 

I do store them in my project directory and not in a seperate svn directory as unittests are directly related to the project state and may differ from state to state. You should just take care that they are not web-accessible.

For example for each state my structure looks like this (using the zend framework), web is the only web-accessible directory:

  • application (controller, configuration)
  • library (zend library, own library)
  • unittests (unittests ;)
  • web (index.php, .htaccess, images and other unexecutables)
  • logs
Fge
The logs directory -- how do you keep it from being overwritten when you export a new version of the site ( if that's how you go about it) ? Is the directory, without the actual logs, in vc or not? Or does `logs` just live independently of vc?
Svn ignores the content of the directory on commit. On Svn update the logs on my live version are already deleted (logrotate + as part of the maintenance process) - that way log entries from older versions don't influence the analysis of the newer version's logs.
Fge
+1  A: 

I would put the unit tests with the rest of your code. Certainly in a separate folder, but it should be with the branch you are working on. I don't see a problem with deploying them to production. You'll probably want to run the tests in production to make sure everything is working with the production php version.

Jon Snyder