You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Paul Michael Reilly <pm...@pajato.com> on 2006/08/16 09:54:09 UTC

Maven2/TestApp/Classpath testing and structuring issues

I am building a long lived Java application (as opposed to a short
lived filter application) that is spawned as a subprocess of some
other application (likely not a JVM).  Commands and responses are
streamed via System.in and System.out, fwiw.

I use the Maven 2 quick start scaffold for this project so far.  In
AppTest, I spawn the app during setup via something like:
Runtime.getRuntime().exec( "java -cp the:class:path com.foo.App" ).

Getting the classpath right for this is proving daunting.  For example
I use JAXB2 and will probably use a few other Maven 2 plug-ins to
create and test the app before I package and ship the app in a jar
file.

So I see two issues immediately: how to set up the classpath for
testing and how to structure the target jar file: whether to include
the dependent libraries (like JAXB) or gracefully fail if the deployed
environment is missing required libraries, something I would rather
avoid.  So, being new to the Maven2 world, I'm looking for some
guidance on how a more experienced Maven2 hacker would approach these
issues.

Thanks,

-pmr

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven2/TestApp/Classpath testing and structuring issues

Posted by Arnaud Bailly <ab...@oqube.com>.
Paul Michael Reilly <pm...@pajato.com> writes:

>
> You qualify. :-)
>

Wait lurking some times on this list and you will find real maven
hackers :-)

>
> The first testing tier will be based on the classes and will be mostly
> traditional unit testing, but I will observe that unit testing has
> never given me much bang for the buck.  Rather it is the integration

Not sure this is the right place to start such a discussion but I
actually found unit testing to be very rewarding if taken
seriously and with the "right" approach. IMHO, unit testing is the
cheapest path towards assessing conformance of a piece of software with its specs,
whether written, implied, formal or otherwise. As a developer, I
*always* found that writting my unit tests gave me insights on my
code, design and implementations. And I have not written a test class
without finding at least one error or mistake. 

> level testing, driven by JUnit, or a JUnit derived framework, like
> Abbot, that I have found to pay big dividends.  But this particular
> App has highlighted opportunities where traditional unit testing may
> offer bigger dividends.  A second testing phase based on the main jar
> artifact is a definite win.


Sure. Good unit test should be coupled with integration and system
test to achieve suitable coverage and confidence level. I try now to
systematically create an it module for my projects that contains such
high-level tests. I did not found the idea but borrowed it from maven
codebase itself which is structured that way.
 

>
> So I like your suggestions and appreciate you taking the time to make
> them.

Always a pleasure and never a waste of time.

regards,
-- 
OQube < software engineering \ génie logiciel >
Arnaud Bailly, Dr.
\web> http://www.oqube.com


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven2/TestApp/Classpath testing and structuring issues

Posted by Paul Michael Reilly <pm...@pajato.com>.
Arnaud Bailly <ab...@oqube.com> writes:

 > Paul Michael Reilly <pm...@pajato.com> writes:
 > 
 > > I use the Maven 2 quick start scaffold for this project so far.  In
 > > AppTest, I spawn the app during setup via something like:
 > > Runtime.getRuntime().exec( "java -cp the:class:path com.foo.App" ).
 > > ...
 > > avoid.  So, being new to the Maven2 world, I'm looking for some
 > > guidance on how a more experienced Maven2 hacker would approach these
 > > issues.
 > >
 > 
 > I am not sure to qualify as an "experienced maven2 hacker" but I am
 > wondering whether it is a good idea to test your whole application in
 > a unit test. To solve the classpath issue, I would rather do the following:
 >  - test my application's classes in unit tests, using the test
 >  classpath provided by maven. You can add <scope>test</scope> to your
 >  dependencies if you want to use libraries in the test phase only. If
 >  I need to test the main class com.foo.App, I just call "main" method
 >  constructing arguments 
 >  - create another project for integration testing that will depend on
 >  my application main artifact and run specific integration tests using
 >  this artifact (eg. jar). That could allow solving the "environment"
 >  issues you hinted at.

You qualify. :-)

Actually your points are well taken.  After thinking about it a bit, I
realize that my "process" needs to be a two tiered testing process,
which probably means abandoning the quick start pom and learning more
about constructing a custom pom.  This is probably a good thing.

The first testing tier will be based on the classes and will be mostly
traditional unit testing, but I will observe that unit testing has
never given me much bang for the buck.  Rather it is the integration
level testing, driven by JUnit, or a JUnit derived framework, like
Abbot, that I have found to pay big dividends.  But this particular
App has highlighted opportunities where traditional unit testing may
offer bigger dividends.  A second testing phase based on the main jar
artifact is a definite win.

So I like your suggestions and appreciate you taking the time to make
them.

-pmr

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven2/TestApp/Classpath testing and structuring issues

Posted by Arnaud Bailly <ab...@oqube.com>.
Paul Michael Reilly <pm...@pajato.com> writes:

> I use the Maven 2 quick start scaffold for this project so far.  In
> AppTest, I spawn the app during setup via something like:
> Runtime.getRuntime().exec( "java -cp the:class:path com.foo.App" ).
> ...
> avoid.  So, being new to the Maven2 world, I'm looking for some
> guidance on how a more experienced Maven2 hacker would approach these
> issues.
>

I am not sure to qualify as an "experienced maven2 hacker" but I am
wondering whether it is a good idea to test your whole application in
a unit test. To solve the classpath issue, I would rather do the following:
 - test my application's classes in unit tests, using the test
 classpath provided by maven. You can add <scope>test</scope> to your
 dependencies if you want to use libraries in the test phase only. If
 I need to test the main class com.foo.App, I just call "main" method
 constructing arguments 
 - create another project for integration testing that will depend on
 my application main artifact and run specific integration tests using
 this artifact (eg. jar). That could allow solving the "environment"
 issues you hinted at.


> Thanks,
>
HIH,
-- 
OQube < software engineering \ génie logiciel >
Arnaud Bailly, Dr.
\web> http://www.oqube.com


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org