On Mon, 2 Apr 2001, Waldhoff, Rodney wrote:

> A small debate has cropped up in the threads on the existing and proposed
> Commons packages about where to put the test classes.
> 
> There are two basic options:
> 
>  1. Place the test cases in their own directory, independent of the classes
> they are testing (e.g., /src/**.java, /test/**.java)
>  
>  2. Place the test cases in with the rest of the source, and use a naming
> convention to distinguish test from non-test classes (e.g,
> /src/**/Test*.java or /src/**/*Test.java, etc.)  The naming convention makes
> it easy to filter the test classes out of production JARs, JavaDocs, etc.,
> as they do in my build.xml examples.
> 
> As you can probably guess from my proposals, I'm a fan of the later (one
> source directory) approach.
> 
> Why?
> 
>  a) The build script and directory organization is simplier.

??? 

What if you want to build only the production classes ? Should we also
build the .class file in that dir because it's simpler ?


>  b) The tests go where the "real classes" go. (The tests are *real classes*,
> they're just not used in production.)  And by "go", I don't just mean that
> they are placed in the same directory tree, but rather that when you build
> one you build the other, when you copy one you copy the other, etc.

Yes, every class is "real" - placing it in a test/ directory doesn't make
them less real, and building is probably not much harder.
 
>  c) It's easy to see which classes are being tested and which are not, which
> in turn encourages more testing.  (To counter Peter's example, in my
> experience this has encouraged more complete testing.)

Maybe we should put the user documentations and examples in that
directory too - that may encourage people to write more documentations :-) 

Ok, reasons not to:

a) Creates a dependency on JUnit ( or whatever testing framework is used
for that tests - JUnit is not the only way to test ). 

b) It's hard to compile the code without the test cases ( I understand you
want to build them togheter, but you can't force everyone to do what you
think is right ). 

c) What happen if people use different testing framework and tools (
please don't tell me JUnit is the only "real" thing ) ?  Do we place all
the test code in the same dir ? 



Costin


Reply via email to