Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Won't Fix
-
2.4.3
-
None
-
None
-
any
-
Patch
Description
There are situations in which you would want to add to surefire classpath an arbitrary resourceSet to have your tests running properly.
To clarify, there are cases in which maven transitive dependency management cannot be enough for having your classpath populated properly, cases in which not even the <additionalClasspathElement> of surefire can be enough, unless you pollute your pom with a huge numer of <additionalClasspathElement> lines (tough to write and maintain).
Maybe an example can clarify the situation:
if you're working with a legacy Webapp, say a WAR built with Ant, that has no POM, but you want to use Maven features to improve testing and to provide a standard approach to lifecycle management. You'd like be able to test in isolation (outside of a container) against the webapp classpath, but while WEB-INF/classes can be loaded with <additionalClasspathElement>, you'd name each and every JAR in the WEB-INF/lib to have the classpath properly populate.
This is infact my case when trying to support Alfresco ECM [1] testing with my maven archetypes [2].
So, after playing around with Java6 classpath wildcard loading [3] (which seems not to be honored by surefire), I wrote this little patch which adds to surefire a new configuration parameter:
<resources>
<resource>
....
</resource>
</resources>
which allows to load arbitrary resources in the surefire classpath, using the usual directory/include/exclude format supported by the Maven DirectoryScanner. This solves my problems as now I can happily load the Alfresco's WEB-INF/lib/*.jar resourceSet.
It does not check for duplicates so it's left to the developer to check it the maven transitive classpath clashes with the added resources (as this should be discouraged, I think it should stay like this).
I understand this should be discouraged, but I could not find a way to work this around (until Alfresco release his POM [4]) in the current surefire setup.
WDYT? Shall I write a test case or you think is never going to make it to the trunk?
[1] http://www.alfresco.com/
[2] http://repository.sourcesense.com/maven2-sites/maven-alfresco-archetypes
[3] http://www.javabeat.net/qna/90-adding-jars-to-the-classpath/
[4] https://issues.alfresco.com/jira/browse/ETHREEOH-1090
Attachments
Attachments
Issue Links
- is related to
-
SUREFIRE-454 To set testResource base on indivdule JUnit test
- Closed
- relates to
-
SUREFIRE-667 Setting up maven resources when testing in addition to testResources
- Closed