ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Quail <m...@cortexebusiness.com.au>
Subject Re: another unit-test question
Date Tue, 04 Mar 2003 23:29:20 GMT
Erik,

It is perfectly acceptable and legal (and desirable) to have the same package 
under two different source trees. So you may have a Foo.java and a FooTest.java 
in package "com.bar"; but you can have them in two different directory structures:

./source/com/bar/Foo.java
./tests/com/bar/FooTest.java

When you compile them, you can compile them to different directories:
./build/classes/com/bar/Foo.class
./build/test-classes/com/bar/FooTest.class

or to the same directory, if you wanted:
./build/classes/com/bar/Foo.class
./build/classes/com/bar/FooTest.class

=Matt

Erik Price wrote:
> I have one other question (where I am uncertain of the "best practice"). 
>  Following along in "Java Development with Ant", in the context of using 
> JUnit for unit testing.
> 
> It is recommended to keep test code separate from production code in the 
> filesystem, using unique directory trees.  This makes sense, because you 
> want to be able to easily copy or access your production code without 
> filtering through files ending with "*Test.java".  But if you don't put 
> the test code in with the production code, how can they share the same 
> package?  It seems to be recommended that unit tests share the same 
> package as the code that they are testing (this is also evident in the 
> example in the book, in which "HtmlDocumentTest" [a unit test] is 
> declared to be in the same package as the production code).
> 
> Should I be copying my production code source tree into a new tree with 
> the test code embedded alongside it?  If so then what happens when I 
> make a change to the source code, I have to first copy it into the test 
> tree so that I can run the unit tests again?
> 
> Sorry, it's a little confusing to me.
> 
> 
> Erik
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 



Mime
View raw message