views:

140

answers:

3

Hi,

I'm using Bazaar for version control, which I'm very happy with. In Bazaar every tree/project in source control is called a 'branch'.

Currently I have a 'main' branch for the actual application, and a 'dev' branch which houses some things like unit tests, as well as the user manual, etc. This way, both the app and its associated tests are versioned, but separately.

However, I suspect that the way I'm doing it is not the best way. For example, if I were to create release branches from that 'main' branch, then these release branches would get out of sync with the unit tests, unless I branched those in the same way.

Currently, in order to create a snapshot of the application, I just export all files from that main branch and zip them up, because there is nothing in that branch's tree that isn't part of the app that will get sent to clients.

What would be a better way to do what I'm doing? Should the unit tests go into that same 'main' branch as the app, and if so what is a convenient way to easily create a 'snapshot' ie the equivalent of a 'daily build' which contains only the files that will be distributed with the app?

Thank you all for your answers. It was hard to decide whose answer to accept. The solution I've gone with is to have my tests within a 'tests' subdirectory of my main tree; I could easily strip that out later if I didn't want to distribute the tests.

+6  A: 

You definitely want to keep your unit tests and code as close as possible. The process we follow is such:

libs/Core/Login.php
libs/Core/Process.php
libs/Core/t/LoginTest.php
libs/Core/t/ProcessTest.php

Basically, create a unit testing module for each part of your code, and separate it from the real code by keeping it in a subdirectory. Then have something go through, find all of the unit testing code and run it before you push to production.

lennysan
Thanks for your answer, it's a neat suggestion. So do you just strip out all the 't' subdirectories when you ship your app (or upload to a public server)?
thomasrutter
We keep it all together, but I could see the need to strip it out.
lennysan
+1  A: 

I'd put main code and tests into one branch, then remove anything you think is extra before packaging.

I think the risk of getting your tests out of sync with the main development work would offset the effort needed to write a script that will clear out files you don't want included before shipping to clients. Just because Bazaar allows for lots of easy branches doesn't mean you'd want to let your tests get too far from the code.

acrosman
+1  A: 

As mentioned by others, tests belong to a specific branch. If one of your code branches is slightly different, it's tests should also probably match that..

Evert