Setting testOutDirectory to ${basedir}/target/test-classes causes test 
classpath to be reversed.
------------------------------------------------------------------------------------------------

                 Key: MNG-3416
                 URL: http://jira.codehaus.org/browse/MNG-3416
             Project: Maven 2
          Issue Type: Bug
          Components: Inheritance and Interpolation
    Affects Versions: 2.0.8
            Reporter: Ben Lidgey


Environment: maven 2.0.8, surefire 2.4.1,2.4.2

 We are running tests using Surefire 2.4.1 and Maven 2.0.8. The Junit  test 
classes are expecting to load a properties file from 
{{src/test/resources}} with the same name as a properties file in 
{{src/main/resources}} to load test data etc. However the src/main/resources 
properties file is being loaded.

Looking at the debug output shows:

[DEBUG] Test Classpath :
[DEBUG]   C:\Documents and
Settings\benl\.m2\repository\junit\junit\4.2\junit-4.2.jar
[more jars]
[DEBUG]   c:\Development\Projects\MyProject\target\classes
[DEBUG]   c:\Development\Projects\MyProject\target\test-classes

Which would explain it. Setting childDelegation to true doesn't get the 
test-classes before classes in the classpath order.

I generated the effective-pom and used it in a copy of the Surefire integration 
test for the classpath order 
(http://svn.apache.org/repos/asf/maven/surefire/trunk/surefire-integration-tests/src/test/resources/classpath-order).
 The tests failed. I then trawled through the project POM and then its parent 
POM commenting out plugins, reporting, dependencies, and other bits until the 
test passed.

The thing that was causing the test to fail was that in the parent POM:
{code:xml}
<defaultGoal>package</defaultGoal>
<directory>target</directory>
<finalName>${pom.artifactId}-${pom.version}</finalName>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
<testOutputDirectory>${basedir}/target/test-classes</testOutputDirectory>
<outputDirectory>${basedir}/target/classes</outputDirectory>
{code}

Changing just testOutputDirectory to
{code:xml}
<testOutputDirectory>target/test-classes</testOutputDirectory>
{code}

Made the tests pass. I've no idea why.

-- 
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