Maven Surefire

Ability to add additions to classpath

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Duplicate
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    N/A
  • Patch Submitted:
    Yes
  • Number of attachments :
    2

Description

There should be a possibility to add arbritary resources to the classpath while executing the tests. These resources would only be available while executing the tests, so they won't be added in the archive.

i suggest a configuration element

<extendedClasspaths>
<extendedClasspath>some/path</extendedClasspath>
<extendedClasspath>/some/other/path</extendedClasspath>
</extendedClasspaths>

This issue somewhat related to http://jira.codehaus.org/browse/MJAR-13 / ability to exclude/include filtering in archiver/jar-plugin

Issue Links

Activity

Hide
David J. M. Karlsen added a comment -

Patch which appends arbritary elements to the surefire classpaths

Show
David J. M. Karlsen added a comment - Patch which appends arbritary elements to the surefire classpaths
Hide
David J. M. Karlsen added a comment -

The first patch was incorrect.
Please delete the first attachment and use this one.

Thanks,

David

Show
David J. M. Karlsen added a comment - The first patch was incorrect. Please delete the first attachment and use this one. Thanks, David
Hide
fabrizio giustina added a comment -

> There should be a possibility to add arbritary resources to the classpath while executing the tests
what about using build/testResources (default directory is /src/test/resources) in pom.xml?

Show
fabrizio giustina added a comment - > There should be a possibility to add arbritary resources to the classpath while executing the tests what about using build/testResources (default directory is /src/test/resources) in pom.xml?
Hide
David J. M. Karlsen added a comment -

If using testresources and resources, the resources will end up in the jar - this is not what we want.
Additionally, if using a targetPath for the testresources, these will not be available on the classpath while executing.

There could also be external resources which has to be available while executing tests.

The proposed patch would fix all these issues.

Show
David J. M. Karlsen added a comment - If using testresources and resources, the resources will end up in the jar - this is not what we want. Additionally, if using a targetPath for the testresources, these will not be available on the classpath while executing. There could also be external resources which has to be available while executing tests. The proposed patch would fix all these issues.
Hide
fabrizio giustina added a comment -

Test resources are NOT added to the main jar. Are you talking about test-jar artifacts maybe?

Show
fabrizio giustina added a comment - Test resources are NOT added to the main jar. Are you talking about test-jar artifacts maybe?
Hide
David J. M. Karlsen added a comment -

Testresources would end up in test-jar, likewise resources would end up in main artifact jar.

Often you want config to be delivered in a separate directory along with you application, so that operations dept. easily can edit this in the runtime environment.

By using the steps proposed in the patch, configuration can be available on cp while executing test, but separated from the jars.

Show
David J. M. Karlsen added a comment - Testresources would end up in test-jar, likewise resources would end up in main artifact jar. Often you want config to be delivered in a separate directory along with you application, so that operations dept. easily can edit this in the runtime environment. By using the steps proposed in the patch, configuration can be available on cp while executing test, but separated from the jars.
Hide
David J. M. Karlsen added a comment -

Anybody willing to patch? (Use the attachment which is 2k, the other file is wrong which is the whole class ).

Show
David J. M. Karlsen added a comment - Anybody willing to patch? (Use the attachment which is 2k, the other file is wrong which is the whole class ).
Hide
Sami Kosonen added a comment -

Thank's, this patch was very helpful. Just I would like to have one more thing added there.

Now in this patch additional classpath elements are added in the classpath and in the surefire classpath, but could it be added also in the Surefire boot classpath?

Currently in the patch:
surefireBooter.addClassPathUrl( classpathElement );
surefireBooter.addSurefireClassPathUrl( classpathElement );

Could there be also:
surefireBooter.addSurefireBootClassPathUrl( classpathElement );

Our project's test cases work only when these classpath elements are added in the Surefire boot classpath. In our case these other two don't help.

Show
Sami Kosonen added a comment - Thank's, this patch was very helpful. Just I would like to have one more thing added there. Now in this patch additional classpath elements are added in the classpath and in the surefire classpath, but could it be added also in the Surefire boot classpath? Currently in the patch: surefireBooter.addClassPathUrl( classpathElement ); surefireBooter.addSurefireClassPathUrl( classpathElement ); Could there be also: surefireBooter.addSurefireBootClassPathUrl( classpathElement ); Our project's test cases work only when these classpath elements are added in the Surefire boot classpath. In our case these other two don't help.
Hide
Ronny Naess added a comment -

Classpath loading issue?

Show
Ronny Naess added a comment - Classpath loading issue?
Hide
John T. Kwon added a comment -

I put the patch in on my machine because I work with Documentum Foundation Classses. These need to have several properties files (dfc.properties) on the classpath in order for the classes to function. Since my unit tests actually run against Documentum, the surefire plugin needs to have this feature in order to specify the classpath during testing.

Show
John T. Kwon added a comment - I put the patch in on my machine because I work with Documentum Foundation Classses. These need to have several properties files (dfc.properties) on the classpath in order for the classes to function. Since my unit tests actually run against Documentum, the surefire plugin needs to have this feature in order to specify the classpath during testing.
Hide
John T. Kwon added a comment -

I'm more than willing to do the patch since I've already done it this morning.

Show
John T. Kwon added a comment - I'm more than willing to do the patch since I've already done it this morning.
Hide
David J. M. Karlsen added a comment -

Please go ahead - what's stopping you?

Show
David J. M. Karlsen added a comment - Please go ahead - what's stopping you?
Hide
John T. Kwon added a comment -

I don't think I have permission to check code in... otherwise, I would put it up there right now.

Show
John T. Kwon added a comment - I don't think I have permission to check code in... otherwise, I would put it up there right now.
Hide
John T. Kwon added a comment -

Please, if someone will let me upload the changes to make this happen, I've already implemented them on my local build, and it works great.

Let me know how I can become a contributor.

Show
John T. Kwon added a comment - Please, if someone will let me upload the changes to make this happen, I've already implemented them on my local build, and it works great. Let me know how I can become a contributor.
Hide
Adrian added a comment -

Will this be fixed soon and added to the 2.3 release? It is very important for our project.

Cheers.

Show
Adrian added a comment - Will this be fixed soon and added to the 2.3 release? It is very important for our project. Cheers.
Hide
Scott LePage added a comment -

Any word on when this might hit the SNAPSHOT code at least? Is this patch viable?

Show
Scott LePage added a comment - Any word on when this might hit the SNAPSHOT code at least? Is this patch viable?
Hide
Peter Anning added a comment -

I don't want to patch core maven I've done this before and it leads to a maintenance headache. For now I am running Junit via the ant plugin but this is not the point of maven. Please can we get this into the core asap.

Cheers
Peter

Show
Peter Anning added a comment - I don't want to patch core maven I've done this before and it leads to a maintenance headache. For now I am running Junit via the ant plugin but this is not the point of maven. Please can we get this into the core asap. Cheers Peter
Hide
Dan Fabulich added a comment -

Duplicate of SUREFIRE-118

Show
Dan Fabulich added a comment - Duplicate of SUREFIRE-118

People

Vote (6)
Watch (8)

Dates

  • Created:
    Updated:
    Resolved: