You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Rick Genter <rg...@interactions.net> on 2011/03/21 14:24:27 UTC
Test phase for a command line tool (resend)
Note: I sent this on Friday (2011-03-18) but saw no response, so am resending on the chance that it somehow got lost in transit.
Caveat: I am new to Maven. I've read the online documentation but haven't found a good source of sample POMs other than for very basic configurations.
I have a POM that builds a command-line tool. I figured out how to use the assembly plugin to build a self-contained jar, but now I need to be able to run a series of test cases using that jar and a custom shell script to invoke it. I have several questions:
1) Where do I put my custom shell script in the hierarchy? I've put the source into src/main/bin for now.
2) For testing I'd like to copy the shell script and self-contained jar (jar-with-dependencies) to a test directory (similar to test-classes) and run the jar from there. How do I do that?
3) The command-line tool analyzes compiled Java code from a jar and builds an XML file from the analysis. What I'd like to do for my test cases is compile a bunch of different tests into different jars, then for each jar run the tool over it, generating an XML file, and do a diff on the XML file against expected output. How do I do that?
3a) Alternatively I could write a test application that used Runtime.exec() to run the tool for each test case, then read in the resulting XML files using an XML parser and made a bunch of assertions about each file, but frankly I'd rather avoid writing the extra code. If I need to, however, how would I do that?
I don't necessarily need the actual POMs written for me; pointers to more complete samples doing similar tasks would be fine. Thanks in advance.
--
Rick Genter
rgenter@interactions.net
*******************************************************************************
This e-mail and any of its attachments may contain Interactions Corporation
proprietary information, which is privileged, confidential, or subject to
copyright belonging to the Interactions Corporation. This e-mail is intended
solely for the use of the individual or entity to which it is addressed. If you
are not the intended recipient of this e-mail, you are hereby notified that any
dissemination, distribution, copying, or action taken in relation to the
contents of and attachments to this e-mail is strictly prohibited and may be
unlawful. If you have received this e-mail in error, please notify the sender
immediately and permanently delete the original and any copy of this e-mail and
any printout. Thank You.
*******************************************************************************
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
RE: Test phase for a command line tool (resend)
Posted by Martin Gainty <mg...@hotmail.com>.
MG>hopefully quick response
> From: rgenter@interactions.net
> Subject: Test phase for a command line tool (resend)
> Date: Mon, 21 Mar 2011 09:24:27 -0400
> CC: rgenter@interactions.net
> To: users@maven.apache.org
>
> Note: I sent this on Friday (2011-03-18) but saw no response, so am resending on the chance that it somehow got lost in transit.
>
> Caveat: I am new to Maven. I've read the online documentation but haven't found a good source of sample POMs other than for very basic configurations.
>
> I have a POM that builds a command-line tool. I figured out how to use the assembly plugin to build a self-contained jar, but now I need to be able to run a series of test cases using that jar and a custom shell script to invoke it. I have several questions:
>
> 1) Where do I put my custom shell script in the hierarchy? I've put the source into src/main/bin for now.
MG>anywhere you want to as long as you chmod +execute for that folder
> 2) For testing I'd like to copy the shell script and self-contained jar (jar-with-dependencies) to a test directory (similar to test-classes) and run the jar from there. How do I do that?
MG>generally in process-resources phase e.g.
<build>
<plugins>
<plugin>
<groupId>Plugin-groupId></plugin>
<artifactId>plugin-artifactId</artifactId>
<version>plugin-version</version>
<executions>
<execution>
<id>process-resources</id>
<phase>process-resources</phase>
<configuration>
<tasks>
<tstamp>
<format property="build.time" pattern="MMM dd, yyyy (hh:mm:ss z)" locale="en" />
</tstamp>
<copy toDir="${basedir}/target/classes/" overwrite="true" filtering="on">
<!-- this will only include files with the xsl extension from ${basedir}/src -->
<fileset dir="${basedir}/src/" includes="**/*.xsl" />
</copy>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
> 3) The command-line tool analyzes compiled Java code from a jar and builds an XML file from the analysis. What I'd like to do for my test cases is compile a bunch of different tests into different jars, then for each jar run the tool over it, generating an XML file, and do a diff on the XML file against expected output. How do I do that?
MG>cygwin has a nice diff tool which you can use
MG>C:\maven-plugin\axis2-aar-maven-plugin\src\modules\codegen>diff --help
MG>Usage: diff [OPTION]... FILES
MG>-r for recursive
MG>FILES are `FILE1 FILE2' or `DIR1 DIR2' or `DIR FILE...' or `FILE... DIR'.
MG>If --from-file or --to-file is given, there are no restrictions on FILES.
MG>If a FILE is `-', read standard input.
MG>Exit status is 0 if inputs are the same, 1 if different, 2 if trouble.
MG>you can use the maven-antrun-plugin and inside build.xml have a default target which runs
MG>exec diff FILE1 FILE2
> 3a) Alternatively I could write a test application that used Runtime.exec() to run the tool for each test case, then read in the resulting XML files using an XML parser and made a bunch of assertions about each file, but frankly I'd rather avoid writing the extra code. If I need to, however, how would I do that?
MG>maven-antrun-plugin and inside build.xml have a target which runs
MG>"java -jar WhateverNameOfJarFile < input"
>
> I don't necessarily need the actual POMs written for me; pointers to more complete samples doing similar tasks would be fine. Thanks in advance.
> --
> Rick Genter
> rgenter@interactions.net
>
>
>
> *******************************************************************************
> This e-mail and any of its attachments may contain Interactions Corporation
> proprietary information, which is privileged, confidential, or subject to
> copyright belonging to the Interactions Corporation. This e-mail is intended
> solely for the use of the individual or entity to which it is addressed. If you
> are not the intended recipient of this e-mail, you are hereby notified that any
> dissemination, distribution, copying, or action taken in relation to the
> contents of and attachments to this e-mail is strictly prohibited and may be
> unlawful. If you have received this e-mail in error, please notify the sender
> immediately and permanently delete the original and any copy of this e-mail and
> any printout. Thank You.
> *******************************************************************************
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
Re: Test phase for a command line tool (resend)
Posted by Anders Hammar <an...@hammar.net>.
I would integrate these integration tests into the build itself. Either in
the maven Project itself (if you only have one project) or in a separate
module. You can use the maven-invoker-plugin for example to execute the
integration tests (along with creating all necessary jars, or whatever, that
you need for the tests).
/Anders
On Mon, Mar 21, 2011 at 14:38, Thomas Sundberg <ts...@kth.se> wrote:
> Hi!
>
> You may some basic poms at my blog, http://thomassundberg.wordpress.com/
>
> I would locate a test script in the project root and have it to point to a
> self-contained jar in ./target
>
> Another option would be to use the Resource plugin,
> http://maven.apache.org/plugins/maven-resources-plugin/ and locate the
> script in any good directory under src.
>
> HTH
> Thomas
>
>
> On Mon, Mar 21, 2011 at 14:24, Rick Genter <rg...@interactions.net>
> wrote:
>
> > Note: I sent this on Friday (2011-03-18) but saw no response, so am
> > resending on the chance that it somehow got lost in transit.
> >
> > Caveat: I am new to Maven. I've read the online documentation but haven't
> > found a good source of sample POMs other than for very basic
> configurations.
> >
> > I have a POM that builds a command-line tool. I figured out how to use
> the
> > assembly plugin to build a self-contained jar, but now I need to be able
> to
> > run a series of test cases using that jar and a custom shell script to
> > invoke it. I have several questions:
> >
> > 1) Where do I put my custom shell script in the hierarchy? I've put the
> > source into src/main/bin for now.
> > 2) For testing I'd like to copy the shell script and self-contained jar
> > (jar-with-dependencies) to a test directory (similar to test-classes) and
> > run the jar from there. How do I do that?
> > 3) The command-line tool analyzes compiled Java code from a jar and
> builds
> > an XML file from the analysis. What I'd like to do for my test cases is
> > compile a bunch of different tests into different jars, then for each jar
> > run the tool over it, generating an XML file, and do a diff on the XML
> file
> > against expected output. How do I do that?
> > 3a) Alternatively I could write a test application that used
> Runtime.exec()
> > to run the tool for each test case, then read in the resulting XML files
> > using an XML parser and made a bunch of assertions about each file, but
> > frankly I'd rather avoid writing the extra code. If I need to, however,
> how
> > would I do that?
> >
> > I don't necessarily need the actual POMs written for me; pointers to more
> > complete samples doing similar tasks would be fine. Thanks in advance.
> > --
> > Rick Genter
> > rgenter@interactions.net
> >
> >
> >
> >
> >
> *******************************************************************************
> > This e-mail and any of its attachments may contain Interactions
> Corporation
> > proprietary information, which is privileged, confidential, or subject to
> > copyright belonging to the Interactions Corporation. This e-mail is
> > intended
> > solely for the use of the individual or entity to which it is addressed.
> If
> > you
> > are not the intended recipient of this e-mail, you are hereby notified
> that
> > any
> > dissemination, distribution, copying, or action taken in relation to the
> > contents of and attachments to this e-mail is strictly prohibited and may
> > be
> > unlawful. If you have received this e-mail in error, please notify the
> > sender
> > immediately and permanently delete the original and any copy of this
> e-mail
> > and
> > any printout. Thank You.
> >
> >
> *******************************************************************************
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>
>
> --
> Thomas Sundberg
> M. Sc. in Computer Science
>
> Mobile: +46 70 767 33 15
> Blog: http://thomassundberg.wordpress.com/
> Twitter: @thomassundberg
>
> Better software through faster feedback
>
Re: Test phase for a command line tool (resend)
Posted by Thomas Sundberg <ts...@kth.se>.
Hi!
You may some basic poms at my blog, http://thomassundberg.wordpress.com/
I would locate a test script in the project root and have it to point to a
self-contained jar in ./target
Another option would be to use the Resource plugin,
http://maven.apache.org/plugins/maven-resources-plugin/ and locate the
script in any good directory under src.
HTH
Thomas
On Mon, Mar 21, 2011 at 14:24, Rick Genter <rg...@interactions.net> wrote:
> Note: I sent this on Friday (2011-03-18) but saw no response, so am
> resending on the chance that it somehow got lost in transit.
>
> Caveat: I am new to Maven. I've read the online documentation but haven't
> found a good source of sample POMs other than for very basic configurations.
>
> I have a POM that builds a command-line tool. I figured out how to use the
> assembly plugin to build a self-contained jar, but now I need to be able to
> run a series of test cases using that jar and a custom shell script to
> invoke it. I have several questions:
>
> 1) Where do I put my custom shell script in the hierarchy? I've put the
> source into src/main/bin for now.
> 2) For testing I'd like to copy the shell script and self-contained jar
> (jar-with-dependencies) to a test directory (similar to test-classes) and
> run the jar from there. How do I do that?
> 3) The command-line tool analyzes compiled Java code from a jar and builds
> an XML file from the analysis. What I'd like to do for my test cases is
> compile a bunch of different tests into different jars, then for each jar
> run the tool over it, generating an XML file, and do a diff on the XML file
> against expected output. How do I do that?
> 3a) Alternatively I could write a test application that used Runtime.exec()
> to run the tool for each test case, then read in the resulting XML files
> using an XML parser and made a bunch of assertions about each file, but
> frankly I'd rather avoid writing the extra code. If I need to, however, how
> would I do that?
>
> I don't necessarily need the actual POMs written for me; pointers to more
> complete samples doing similar tasks would be fine. Thanks in advance.
> --
> Rick Genter
> rgenter@interactions.net
>
>
>
>
> *******************************************************************************
> This e-mail and any of its attachments may contain Interactions Corporation
> proprietary information, which is privileged, confidential, or subject to
> copyright belonging to the Interactions Corporation. This e-mail is
> intended
> solely for the use of the individual or entity to which it is addressed. If
> you
> are not the intended recipient of this e-mail, you are hereby notified that
> any
> dissemination, distribution, copying, or action taken in relation to the
> contents of and attachments to this e-mail is strictly prohibited and may
> be
> unlawful. If you have received this e-mail in error, please notify the
> sender
> immediately and permanently delete the original and any copy of this e-mail
> and
> any printout. Thank You.
>
> *******************************************************************************
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
--
Thomas Sundberg
M. Sc. in Computer Science
Mobile: +46 70 767 33 15
Blog: http://thomassundberg.wordpress.com/
Twitter: @thomassundberg
Better software through faster feedback