You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Dave Ford <df...@smart-soft.com> on 2003/07/12 18:20:07 UTC
Keeping your test source code in a separate, but parallel source tree
The Maven web site lists "Keeping your test source code in a separate, but
parallel source tree" as best practices.
Q1: Why is this a best practice? It just seems like an extra thing to
maintain to me, making package name refactoring for troublesome. I've been
placing my test class next to the tested class.
smartsoft.util.Date
smartsoft.util.DateTest
By naming them this way, they appear next to each other in dir listings.
Q2: If I want to continue my practice of keeping them together, is there any
way to get Maven to support that?
Thanks
Dave Ford
Smart Soft - The Developer Training Company
http://www.smart-soft.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Keeping your test source code in a separate, but parallel
source tree
Posted by Jason van Zyl <ja...@zenplex.com>.
On Sat, 2003-07-12 at 12:20, Dave Ford wrote:
> The Maven web site lists "Keeping your test source code in a separate, but
> parallel source tree" as best practices.
>
> Q1: Why is this a best practice? It just seems like an extra thing to
> maintain to me, making package name refactoring for troublesome.
Why is it troublesome? I refactor things on a daily basis and I don't
have any trouble with test sources in a different directory.
It makes running test easier, makes adding test classes to the classpath
easier, makes it easier generally for packaging. Just having them
separated makes many more things possible.
> I've been
> placing my test class next to the tested class.
>
> smartsoft.util.Date
> smartsoft.util.DateTest
>
> By naming them this way, they appear next to each other in dir listings.
>
> Q2: If I want to continue my practice of keeping them together, is there any
> way to get Maven to support that?
You can probably roll something if you like, don't know how easy it is
but it will never, ever, be supported in Maven as an accepted practice.
> Thanks
>
>
> Dave Ford
> Smart Soft - The Developer Training Company
> http://www.smart-soft.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
--
jvz.
Jason van Zyl
jason@zenplex.com
http://tambora.zenplex.org
In short, man creates for himself a new religion of a rational
and technical order to justify his work and to be justified in it.
-- Jacques Ellul, The Technological Society
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Keeping your test source code in a separate, but parallel
source tree
Posted by Jason van Zyl <ja...@zenplex.com>.
On Sat, 2003-07-12 at 20:02, Dave Ford wrote:
> So, back to my question. Why is this a best practice?
It's what we have chosen for reasons I mentioned in my previous email
and we've embodied those choices in the test plugin.
> Maybe it's a common
> practices, possibly a standard practiced, but no one has yet convinced me
> it's best practice.
No one is trying to convince you. If you don't like it make your own
test plugin as it will take you all of 10 minutes and you can put all
your sourcecode in one directory if you like.
>
> Dave Ford
> Smart Soft - The Developer Training Company
> http://www.smart-soft.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
--
jvz.
Jason van Zyl
jason@zenplex.com
http://tambora.zenplex.org
In short, man creates for himself a new religion of a rational
and technical order to justify his work and to be justified in it.
-- Jacques Ellul, The Technological Society
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
RE: Keeping your test source code in a separate, but parallel source tree
Posted by Tom Copeland <to...@infoether.com>.
> So, back to my question. Why is this a best practice? Maybe
> it's a common
> practices, possibly a standard practiced, but no one has yet
> convinced me
> it's best practice.
FWIW, I like the separate package hierarchy because it keeps the
"regular" code packages less cluttered. I feel like 10 classes in a
package is OK... but if there were 20 classes, 10 of which were tests,
and they were all intermingled.... just seems like it would be visually
distracting.
Yours,
Tom Copeland
tom@infoether.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Keeping your test source code in a separate, but parallel source
tree
Posted by Luke Taylor <ne...@freesurf.ch>.
Geir Magnusson Jr. wrote:
>
> On Saturday, July 12, 2003, at 08:02 PM, Dave Ford wrote:
>
>>> The advantage I see is that you get to have test code that has
>>> package-level access
>>
>> Actually, you get that by placing them in the same directory also. So
>> that's
>> not really an advantage.
>>
>>> and because it's in a separate tree, it's easy to
>>> build binaries that don't include all the test code...
>>
>> Obviously, this is easily accomplished by tools such as Ant or Maven by
>> simply excluding *Test
>
>
> That assumes that your test code is so simple that everything fits a
> pattern like that. If so, yes, your are right. But when there's other
> code that isn't *Test, then it helps to be able to have a separate tree....
>
Yes, it should be obvious that there are likely to be different files in
the test tree - the tests may use mock objects, xml and properties
config files and so on. You generally don't want to supply your users
with javadoc for your test classes either.
It also makes it much more obvious to someone trying to get to grips
with the codebase for the first time what is providing the key
functionality and what is just testing it. Division along clear lines of
responsibility is generally a good thing (not just for tests).
--
Luke Taylor. Monkey Machine Ltd.
PGP Key ID: 0x57E9523C http://www.monkeymachine.ltd.uk
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Keeping your test source code in a separate, but parallel source tree
Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On Saturday, July 12, 2003, at 08:02 PM, Dave Ford wrote:
>> The advantage I see is that you get to have test code that has
>> package-level access
> Actually, you get that by placing them in the same directory also. So
> that's
> not really an advantage.
>
>> and because it's in a separate tree, it's easy to
>> build binaries that don't include all the test code...
> Obviously, this is easily accomplished by tools such as Ant or Maven by
> simply excluding *Test
That assumes that your test code is so simple that everything fits a
pattern like that. If so, yes, your are right. But when there's other
code that isn't *Test, then it helps to be able to have a separate
tree....
geir
>
> So, back to my question. Why is this a best practice? Maybe it's a
> common
> practices, possibly a standard practiced, but no one has yet convinced
> me
> it's best practice.
>
> Dave Ford
> Smart Soft - The Developer Training Company
> http://www.smart-soft.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
>
--
Geir Magnusson Jr 203-956-2604(w)
Adeptra, Inc. 203-434-2093(m)
geirm@adeptra.com 203-247-1713(m)
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Keeping your test source code in a separate, but parallel source tree
Posted by Dave Ford <df...@smart-soft.com>.
> The advantage I see is that you get to have test code that has
> package-level access
Actually, you get that by placing them in the same directory also. So that's
not really an advantage.
> and because it's in a separate tree, it's easy to
> build binaries that don't include all the test code...
Obviously, this is easily accomplished by tools such as Ant or Maven by
simply excluding *Test
So, back to my question. Why is this a best practice? Maybe it's a common
practices, possibly a standard practiced, but no one has yet convinced me
it's best practice.
Dave Ford
Smart Soft - The Developer Training Company
http://www.smart-soft.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
RE: Keeping your test source code in a separate, but parallel
source tree
Posted by Jason van Zyl <ja...@zenplex.com>.
On Sat, 2003-07-12 at 13:57, Brendan Lawlor wrote:
> I do exactly as Dave Ford does - I keep my unit test classes in the same
> packages as the production code under test. I find it good for the same
> reasons as Dave outlines, and separating them at delivery time using ant
> <excludes> in a fileset is very very simple (once you stick to a consistent
> naming convention). I took this practise from some junit documentation I
> read.
>
> There's probably little point in discussing the merits and demerits of this
> practice: it's enough perhaps to say that a lot of developers do things in
> both ways and it would be great of maven could facilitate both approaches.
Never going to happen and I make no apologies for that.
> Brendan.
>
> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@adeptra.com]
> Sent: 12 July 2003 17:59
> To: Maven Users List
> Subject: Re: Keeping your test source code in a separate, but parallel
> source tree
>
>
>
> On Saturday, July 12, 2003, at 12:20 PM, Dave Ford wrote:
>
> > The Maven web site lists "Keeping your test source code in a separate,
> > but
> > parallel source tree" as best practices.
> >
> > Q1: Why is this a best practice? It just seems like an extra thing to
> > maintain to me, making package name refactoring for troublesome. I've
> > been
> > placing my test class next to the tested class.
> >
> > smartsoft.util.Date
> > smartsoft.util.DateTest
> >
> > By naming them this way, they appear next to each other in dir
> > listings.
>
> True, although I rarely ever go digging around in the directory to see
> what's there. Generally tools do a good job, such as Eclipse or Idea.
>
> The advantage I see is that you get to have test code that has
> package-level access and because it's in a separate tree, it's easy to
> build binaries that don't include all the test code...
>
> geir
>
> >
> > Q2: If I want to continue my practice of keeping them together, is
> > there any
> > way to get Maven to support that?
> >
> > Thanks
> >
> >
> > Dave Ford
> > Smart Soft - The Developer Training Company
> > http://www.smart-soft.com
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
> >
> --
> Geir Magnusson Jr 203-956-2604(w)
> Adeptra, Inc. 203-434-2093(m)
> geirm@adeptra.com 203-247-1713(m)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
--
jvz.
Jason van Zyl
jason@zenplex.com
http://tambora.zenplex.org
In short, man creates for himself a new religion of a rational
and technical order to justify his work and to be justified in it.
-- Jacques Ellul, The Technological Society
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Keeping your test source code in a separate, but parallel
source tree
Posted by Jason van Zyl <ja...@zenplex.com>.
On Sat, 2003-07-12 at 14:43, Bill Lynch wrote:
> I agree - I prefer to manage 2 separate directories and I think it's easier to
> understand projects if they're structured that way. But, I do think you're right
> - it'd be great if Maven could handle either approach.
Well, I don't think it would be great. Where does it stop then, you just
end up with a jumble. One user wants this way, another wants that we
allow N different setups for a slew of things and you just end up with a
morass again. It's something that I will not let happen so long as I'm
around here.
> Couldn't Maven pull test cases given a dir and a patternset? I don't see why
> technically it has to be in a seperate directory.
Technically nothing is impossible but that's not generally why we decide
to do things a particular way. I realize that in many cases some
compromises are made and not every single user's desires are satisfied
but that's something I can live with and I honestly thing in the long
run it will better serve new users to Maven.
> Regards,
> --Bill
>
>
>
> > -----Original Message-----
> > From: Geir Magnusson Jr. [mailto:geirm@adeptra.com]
> > Sent: 12 July 2003 17:59
> > To: Maven Users List
> > Subject: Re: Keeping your test source code in a separate, but parallel
> > source tree
> >
> >
> >
> > On Saturday, July 12, 2003, at 12:20 PM, Dave Ford wrote:
> >
> >
> >>The Maven web site lists "Keeping your test source code in a separate,
> >>but
> >>parallel source tree" as best practices.
> >>
> >>Q1: Why is this a best practice? It just seems like an extra thing to
> >>maintain to me, making package name refactoring for troublesome. I've
> >>been
> >>placing my test class next to the tested class.
> >>
> >>smartsoft.util.Date
> >>smartsoft.util.DateTest
> >>
> >>By naming them this way, they appear next to each other in dir
> >>listings.
> >
> >
> > True, although I rarely ever go digging around in the directory to see
> > what's there. Generally tools do a good job, such as Eclipse or Idea.
> >
> > The advantage I see is that you get to have test code that has
> > package-level access and because it's in a separate tree, it's easy to
> > build binaries that don't include all the test code...
> >
> > geir
> >
> >
> >>Q2: If I want to continue my practice of keeping them together, is
> >>there any
> >>way to get Maven to support that?
> >>
> >>Thanks
> >>
> >>
> >>Dave Ford
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
--
jvz.
Jason van Zyl
jason@zenplex.com
http://tambora.zenplex.org
In short, man creates for himself a new religion of a rational
and technical order to justify his work and to be justified in it.
-- Jacques Ellul, The Technological Society
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Keeping your test source code in a separate, but parallel source
tree
Posted by Bill Lynch <bi...@jivesoftware.com>.
Brendan,
> I do exactly as Dave Ford does - I keep my unit test classes in the same
> packages as the production code under test. I find it good for the same
> reasons as Dave outlines, and separating them at delivery time using ant
> <excludes> in a fileset is very very simple (once you stick to a consistent
> naming convention). I took this practise from some junit documentation I
> read.
It is pretty easy to exclude/include files from a release or build. I like to
keep them separate so my tests don't pollute my main source, and I find that I
have utility classes needed for my tests (that may or may not follow the
*Test.java convention) and I don't want those in my main source either.
> There's probably little point in discussing the merits and demerits of this
> practice: it's enough perhaps to say that a lot of developers do things in
> both ways and it would be great of maven could facilitate both approaches.
I agree - I prefer to manage 2 separate directories and I think it's easier to
understand projects if they're structured that way. But, I do think you're right
- it'd be great if Maven could handle either approach.
Couldn't Maven pull test cases given a dir and a patternset? I don't see why
technically it has to be in a seperate directory.
Regards,
--Bill
> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@adeptra.com]
> Sent: 12 July 2003 17:59
> To: Maven Users List
> Subject: Re: Keeping your test source code in a separate, but parallel
> source tree
>
>
>
> On Saturday, July 12, 2003, at 12:20 PM, Dave Ford wrote:
>
>
>>The Maven web site lists "Keeping your test source code in a separate,
>>but
>>parallel source tree" as best practices.
>>
>>Q1: Why is this a best practice? It just seems like an extra thing to
>>maintain to me, making package name refactoring for troublesome. I've
>>been
>>placing my test class next to the tested class.
>>
>>smartsoft.util.Date
>>smartsoft.util.DateTest
>>
>>By naming them this way, they appear next to each other in dir
>>listings.
>
>
> True, although I rarely ever go digging around in the directory to see
> what's there. Generally tools do a good job, such as Eclipse or Idea.
>
> The advantage I see is that you get to have test code that has
> package-level access and because it's in a separate tree, it's easy to
> build binaries that don't include all the test code...
>
> geir
>
>
>>Q2: If I want to continue my practice of keeping them together, is
>>there any
>>way to get Maven to support that?
>>
>>Thanks
>>
>>
>>Dave Ford
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
RE: Keeping your test source code in a separate, but parallel source tree
Posted by Brendan Lawlor <br...@spokesoft.com>.
I do exactly as Dave Ford does - I keep my unit test classes in the same
packages as the production code under test. I find it good for the same
reasons as Dave outlines, and separating them at delivery time using ant
<excludes> in a fileset is very very simple (once you stick to a consistent
naming convention). I took this practise from some junit documentation I
read.
There's probably little point in discussing the merits and demerits of this
practice: it's enough perhaps to say that a lot of developers do things in
both ways and it would be great of maven could facilitate both approaches.
Brendan.
-----Original Message-----
From: Geir Magnusson Jr. [mailto:geirm@adeptra.com]
Sent: 12 July 2003 17:59
To: Maven Users List
Subject: Re: Keeping your test source code in a separate, but parallel
source tree
On Saturday, July 12, 2003, at 12:20 PM, Dave Ford wrote:
> The Maven web site lists "Keeping your test source code in a separate,
> but
> parallel source tree" as best practices.
>
> Q1: Why is this a best practice? It just seems like an extra thing to
> maintain to me, making package name refactoring for troublesome. I've
> been
> placing my test class next to the tested class.
>
> smartsoft.util.Date
> smartsoft.util.DateTest
>
> By naming them this way, they appear next to each other in dir
> listings.
True, although I rarely ever go digging around in the directory to see
what's there. Generally tools do a good job, such as Eclipse or Idea.
The advantage I see is that you get to have test code that has
package-level access and because it's in a separate tree, it's easy to
build binaries that don't include all the test code...
geir
>
> Q2: If I want to continue my practice of keeping them together, is
> there any
> way to get Maven to support that?
>
> Thanks
>
>
> Dave Ford
> Smart Soft - The Developer Training Company
> http://www.smart-soft.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
>
--
Geir Magnusson Jr 203-956-2604(w)
Adeptra, Inc. 203-434-2093(m)
geirm@adeptra.com 203-247-1713(m)
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Keeping your test source code in a separate, but parallel source tree
Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On Saturday, July 12, 2003, at 12:20 PM, Dave Ford wrote:
> The Maven web site lists "Keeping your test source code in a separate,
> but
> parallel source tree" as best practices.
>
> Q1: Why is this a best practice? It just seems like an extra thing to
> maintain to me, making package name refactoring for troublesome. I've
> been
> placing my test class next to the tested class.
>
> smartsoft.util.Date
> smartsoft.util.DateTest
>
> By naming them this way, they appear next to each other in dir
> listings.
True, although I rarely ever go digging around in the directory to see
what's there. Generally tools do a good job, such as Eclipse or Idea.
The advantage I see is that you get to have test code that has
package-level access and because it's in a separate tree, it's easy to
build binaries that don't include all the test code...
geir
>
> Q2: If I want to continue my practice of keeping them together, is
> there any
> way to get Maven to support that?
>
> Thanks
>
>
> Dave Ford
> Smart Soft - The Developer Training Company
> http://www.smart-soft.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
>
--
Geir Magnusson Jr 203-956-2604(w)
Adeptra, Inc. 203-434-2093(m)
geirm@adeptra.com 203-247-1713(m)
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org