4 Replies - 1083 Views - Last Post: 02 April 2013 - 08:48 PM

#1 cfoley  Icon User is online

  • Cabbage
  • member icon

Reputation: 2002
  • View blog
  • Posts: 4,167
  • Joined: 11-December 07

Where do you put your test code?

Posted 02 April 2013 - 06:35 AM

I guess the real question more cross-cutting. It has to do with IDE setup, version control and deployment. Let me start with the motivating example of my typical Eclipse setup. I'd love some feedback on what I'm doing right and what I'm doing wrong. Alternatively, I'd like to hear if you do things differently.

I have a different workspace for each piece of software I'm working on. Each workspace has at least three projects: main, test and sandbox. These are for the code of the software, the unit tests and somewhere for me to experiment with throw-away code. I often add more projects for libraries or even to split up the main project.

For version control, I use Git and Github. The workspace directory is the git directory, and I do my best to add all the Eclipse stuff and other nasties to .ignore.

Deployment is something I could definitely do better on. I tend to just build a jar when I need to deploy something.

Visual Studio is similar, replacing Workspace for Solution.


So, I'd like to hear what you think. I'm especially interested in the location of unit tests. Do you keep them in a separate project? Do you mix them in with your application source files? Do you have a main/src and a test/src folder in your application project.

Is This A Good Question/Topic? 0
  • +

Replies To: Where do you put your test code?

#2 stackoverflow  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 165
  • View blog
  • Posts: 545
  • Joined: 06-July 11

Re: Where do you put your test code?

Posted 02 April 2013 - 11:04 AM

View Postcfoley, on 02 April 2013 - 01:35 PM, said:




I use the following layout:

dep/
lib/
src/
test/
makefile
readme.md
license.txt
.gitignore

Where dep is third party dependencies that need to be installed. The lib folder is for third party APIs (header + dll combos), src is for source code that pertains to the releasable product. The test folder is for any testing apps, unit tests etc.

I always add bin, obj and any build folders to the ignore list as well as any project or tool settings or OS files.

I don't use IDEs. I typically use Vim and makefiles for everything I do.

This post has been edited by stackoverflow: 02 April 2013 - 11:05 AM

Was This Post Helpful? 1
  • +
  • -

#3 cfoley  Icon User is online

  • Cabbage
  • member icon

Reputation: 2002
  • View blog
  • Posts: 4,167
  • Joined: 11-December 07

Re: Where do you put your test code?

Posted 02 April 2013 - 11:37 AM

Looks good. That's the kind of layout I maybe should start using. Assuming you use XUnit for testing, where do you put it? Does the makefile prevent it being deployed?
Was This Post Helpful? 0
  • +
  • -

#4 stackoverflow  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 165
  • View blog
  • Posts: 545
  • Joined: 06-July 11

Re: Where do you put your test code?

Posted 02 April 2013 - 05:53 PM

Yep, I use different make configurations.. make debug, make release, make test etc.
Was This Post Helpful? 1
  • +
  • -

#5 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3576
  • View blog
  • Posts: 11,126
  • Joined: 05-May 12

Re: Where do you put your test code?

Posted 02 April 2013 - 08:48 PM

For personal projects, I tend to follow stackoverflow's layout, but have a MSBuild .proj or a jamfile instead of a makefile at the root. For work projects or stuff that I need to collaborate with others who don't use the command line as much, the src/ and test/ directories get coalesced into a single directory like so:
.hgignore
tools/
lib/
docs/
src/
    projA/
    test.projA/
    projB/
    test.projB/
    solution.sln



This is mostly to encourage test driven development. When somebody rebuilds the solution, they automatically rebuild (and run) the unit tests.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1