Hmmm, this might not work as good as I thought it did.  It seems when the
antrun plugin fails during integration testing, the antrun plugin running
the tests doesn't catch and report the failure.  Any idea how to fix this?

     [exec] [ERROR] BUILD ERROR
     [exec] [INFO]
------------------------------------------------------------------------
     [exec] [INFO] Error executing ant tasks

     [exec] Embedded error: The following error occurred while executing
this line:
     [exec]
/Users/mraible/Work/appfuse-2.0/archetypes/appfuse-basic-spring/target/basicspring/src/test/resources/web-tests.xml:23:
Canoo Webtest: R_1454.
     [exec] Test failed.
     [exec] Test step steps
(/Users/mraible/Work/appfuse-2.0/archetypes/appfuse-basic-spring/target/basicspring/src/test/resources/web-tests.xml:25:
) null failed with message "Step[invoke "get Login Page" (1/6)]: HTTP error
400, at: invoke"
     [exec] [INFO]
------------------------------------------------------------------------
     [exec] [INFO] For more information, run Maven with the -e switch
     [exec] [INFO]
------------------------------------------------------------------------
     [exec] [INFO] Total time: 22 seconds
     [exec] [INFO] Finished at: Sat Feb 03 12:41:58 MST 2007
     [exec] [INFO] Final Memory: 22M/508M
     [exec] [INFO]
------------------------------------------------------------------------
     [exec] Result: 1
[INFO] Executed tasks
[INFO] [install:install]
[INFO] Installing
/Users/mraible/Work/appfuse-2.0/archetypes/appfuse-basic-spring/target/appfuse-basic-spring-1.0-m3-SNAPSHOT.jar
to
/Users/mraible/.m2/repository/org/appfuse/appfuse-basic-spring/1.0-m3-SNAPSHOT/appfuse-basic-spring-1.0-m3-SNAPSHOT.jar
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 29 seconds
[INFO] Finished at: Sat Feb 03 12:41:58 MST 2007
[INFO] Final Memory: 8M/508M
[INFO]
------------------------------------------------------------------------

Thanks,

Matt


mraible wrote:
> 
> I've figured out a way to test archetypes with Ant, but it's not quite as
> clean as I'd like.  In my archetypes directory, I have a
> common-test.xml[1] file that gets called from the archetype using the
> antrun-plugin:
> 
> The following works:
> 
>                     <plugin>
>                         <artifactId>maven-antrun-plugin</artifactId>
>                         <version>1.1</version>
>                         <configuration>
>                             <tasks>
>                                 <ant antfile="test.xml"/>
>                             </tasks>
>                         </configuration>
>                         <executions>
>                             <execution>
>                                 <phase>integration-test</phase>
>                                 <goals>
>                                     <goal>run</goal>
>                                 </goals>
>                             </execution>
>                         </executions>
>                     </plugin>
> 
> If test.xml has:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <project name="integration-test" basedir="." default="test">
>     
>     <!-- Import macrodefs for running Maven to create archetypes and run
> integration tests -->
>     <import file="../common-test.xml"/>
>     
>     <target name="test" description="Tests that 'mvn integration-test'
> works with archetype">
>         <test archetype="appfuse-basic-jsf" name="basicjsf"
> version="1.0-m3-SNAPSHOT"/>
>     </target>
> </project>
> 
> Is it possible to move the contents from test.xml into the pom.xml itself? 
> When I try to use the following, it fails with a NPE:
> 
>                             <tasks>
>                                 <import file="../common-test.xml"/>
>                                 <test archetype="appfuse-basic-jsf"
> name="basicjsf" 
>                                     version="1.0-m3-SNAPSHOT"/>
>                             </tasks>
> 
> Error:
> 
> Embedded error: java.lang.NullPointerException
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Trace
> org.apache.maven.lifecycle.LifecycleExecutionException: Error executing
> ant tasks
>         at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:559)
>         at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:475)
>         at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:454)
>         at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:306)
>         at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:273)
>         at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:140)
>         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
>         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
>         at org.apache.maven.cli.MavenCli.main(MavenCli.java:256)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:585)
>         at
> org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
>         at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
>         at
> org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)       
> at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
> Caused by: org.apache.maven.plugin.MojoExecutionException: Error executing
> ant tasks
>         at
> org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:114)
>         at
> org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:83)       
> at
> org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:412)
>         at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:534)
>         ... 16 more
> Caused by: java.lang.NullPointerException
>         at org.apache.tools.ant.Task.perform(Task.java:373)
>         at org.apache.tools.ant.Target.execute(Target.java:341)
>         at
> org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:108)
>         ... 19 more
> Caused by: java.lang.NullPointerException
>         at
> org.apache.tools.ant.taskdefs.ImportTask.execute(ImportTask.java:96)
>         at
> org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
>         at org.apache.tools.ant.Task.perform(Task.java:364)
>         ... 21 more
> 
> Does the antrun plugin support imports?
> 
> Is this the best way to test archetypes?
> 
> Thanks,
> 
> Matt
> 
> [1] common-test.xml:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- This file is imported in the archetype pom.xml files for integration
> tests -->
> <project>
>     <macrodef name="test">
>         <attribute name="name"/>
>         <attribute name="archetype"/>
>         <attribute name="version"/>
>         
>         <sequential>
>             <delete dir="target/@{name}"/>
>             <maven dir="target" name="@{name}" archetype="@{archetype}"
> version="@{version}" />
>             <maven dir="target/@{name}" command="integration-test"/>
>         </sequential>
>     </macrodef>
>     
>     <macrodef name="maven">
>         <attribute name="dir" default="${basedir}"/>
>         <attribute name="name" default=""/>
>         <attribute name="archetype" default=""/>
>         <attribute name="version" default=""/>
>         <attribute name="command" default="archetype:create
> -DarchetypeGroupId=org.appfuse [EMAIL PROTECTED]
> -DremoteRepositories=http://static.appfuse.org/repository
> [EMAIL PROTECTED] -DgroupId=com.mycompany
> [EMAIL PROTECTED]"/>
>         
>         <sequential>
>             <exec dir="@{dir}" executable="mvn.bat" os="Windows XP">
>                 <arg line="@{command}"/>
>             </exec>
>             <exec dir="@{dir}" executable="mvn" os="Mac OS X">
>                 <arg line="@{command}"/>
>             </exec>
>             <exec dir="@{dir}" executable="mvn" os="Linux">
>                 <arg line="@{command}"/>
>             </exec>
>         </sequential>
>     </macrodef>
> </project>
> 

-- 
View this message in context: 
http://www.nabble.com/Testing-archetypes-with-Ant-tf3167091s177.html#a8788272
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to