+5  A: 

Since the tests should be versioned along with the code they run against, (2) makes more sense imo. Keeping them together in the same hierarchy reduces the possibility of staleness issues and raises any conflicts earlier in the development cycle.


Note: The OP has clarified that the tests directory should indeed be under trunk.

John Feminella
+1  A: 

You might try something like:

  • Project
    • ProjectA
      • tags
      • branches
      • trunk
        • lib
        • doc
        • src
        • tests
        • samples

This organization keeps an entire project, including its tests and samples (which are in fact part of the project as a whole), within a single versioned tree in source control.

Justice
I was going to do that but the samples may contain large files for the demos and I don't want to have to check them out every time I need to edit the source code of ProjectA
Nathan W
Then you may think about creating a more complex directory structure for your project, *within* /Project/ProjectA/trunk/. However, I would recommend ensuring, any time you make a change, that all samples compile and all tests on the samples pass - and it would be easiest to accomplish this with by checking out the whole tree.
Justice
+2  A: 

The source code and tests should be always together, both under trunk. So the repository layout in SVN would be like this:

  • ProjectA
    • branches
    • tags
    • trunk
      • src
      • test
      • lib
  • ProjectA-Examples
    • branches
    • tags
    • trunk
      • src
      • lib

Another possibility would be to store the examples together with the main codebase. If the examples are small and you redistribute the examples together with the main codebase, this would make more sense.

  • ProjectA
    • branches
    • tags
    • trunk
      • src
      • test
      • lib
      • examples

On the other hand, if the examples are moderate-sized example applications, then each example might be best as its own project.

Esko Luontola
Opps my bad, test were supposed to be in trunk but I stuffed up the image.
Nathan W