[ 
http://jira.codehaus.org/browse/SUREFIRE-443?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=154697#action_154697
 ] 

Anthony Whitford commented on SUREFIRE-443:
-------------------------------------------

For those of us using JPA, EJB3, and the [Seam 
Framework|http://www.seamframework.org/], this is a pretty *BIG* deal.  It 
would be great to have this feature so that we can easily use _SeamTest_, gain 
accurate coverage analysis, and overall promote the right thing:  write tests!

> Provide option to merge test classpath into one directory
> ---------------------------------------------------------
>
>                 Key: SUREFIRE-443
>                 URL: http://jira.codehaus.org/browse/SUREFIRE-443
>             Project: Maven Surefire
>          Issue Type: New Feature
>          Components: classloading
>    Affects Versions: 2.4
>         Environment: Maven 2.0.8
>            Reporter: Cory Prowse
>            Priority: Minor
>             Fix For: Future
>
>
> Please provide an option for the test classpath to be merged into one 
> directory.
> Maven sets up the class files as follows:
> {noformat}
> |-- target/test-classes
> |   `-- Unit Test classes
> |-- target/classes
>     `-- Classes to be tested
> {noformat}
> When running unit tests, the desired outcome is for any file in the 
> "target/test-classes" tree to override those in the "target/classes".  
> Specifically that any file in classes is ignored and overridden by the file 
> in test-classes for the tests to work as expected.
> (In a sense a union on these two file trees in the order specified)
> The problem arises when using a container such as Embedded JBoss to test 
> which treats each directory as a separate scope for classloading.
> Reading the ejb-3_0-fr-spec-persistence.pdf section "6.2.2 Persistence Unit 
> Scope" spells it out quite clearly (a very short one page read) that if the 
> "target/test-classes" and "target/classes" are each treated as a separate 
> ejb-jar, then the runtime environment is not going to work due to these 
> scoping rules.
> I have an ugly hack in place as follows which has the desired effect, but it 
> would be more preferable if instead Maven Surefire provided an option to 
> merge the directories together and have just one directory in the test 
> classpath.
> {noformat}
> <build>
>         <plugins>
>             ...
>             <plugin>
>                 <!-- This correctly merges the test-classes and classes 
> directories for an EE container -->
>                 <artifactId>maven-antrun-plugin</artifactId>
>                 <executions>
>                     <execution>
>                         <id>setupTestClasspath</id>
>                         <phase>test-compile</phase>
>                         <configuration>
>                             <tasks>
>                                 <echo message="Setting up a single merged 
> test classpath directory" />
>                                 <!-- move the originals -->
>                                 <mkdir dir="${basedir}/target/tmp" />
>                                 <move file="${basedir}/target/classes" 
> todir="${basedir}/target/tmp" />
>                                 <move file="${basedir}/target/test-classes" 
> todir="${basedir}/target/tmp" />
>                                 <!-- Merge into new directory -->
>                                 <copy todir="${basedir}/target/test-classes" 
> overwrite="true">
>                                     <fileset 
> dir="${basedir}/target/tmp/test-classes" />
>                                 </copy>
>                                 <copy todir="${basedir}/target/test-classes" 
> overwrite="false">
>                                     <fileset 
> dir="${basedir}/target/tmp/classes" />
>                                 </copy>
>                                 <mkdir dir="${basedir}/target/classes" />
>                             </tasks>
>                         </configuration>
>                         <goals>
>                             <goal>run</goal>
>                         </goals>
>                     </execution>
>                     <execution>
>                         <id>restoreTestClasspath</id>
>                         <phase>test</phase>
>                         <configuration>
>                             <tasks>
>                                 <echo message="Restoring original classes 
> directories" />
>                                 <delete dir="${basedir}/target/classes" />
>                                 <move file="${basedir}/target/test-classes" 
> tofile="${basedir}/target/test-classes-MERGED" />
>                                 <move file="${basedir}/target/tmp/classes" 
> todir="${basedir}/target" />
>                                 <move 
> file="${basedir}/target/tmp/test-classes" todir="${basedir}/target" />
>                             </tasks>
>                         </configuration>
>                         <goals>
>                             <goal>run</goal>
>                         </goals>
>                     </execution>
>                 </executions>
>             </plugin>
>             ...
> {noformat}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to