|
|
|
Simply add the following to the pom of any module that has test-classes that you want jarred up. For example, when added to 'appfuse/data/hibernate/pom.xml', you'll get a jar named 'appfuse-hibernate-2.0-SNAPSHOT-tests.jar' in the target directory.
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <executions> <execution> <goals> <goal>test-jar</goal> </goals> </execution> </executions> </plugin> I was going to simply move BaseDaoTestCase (and others) into the "src/main/java" folder for each module. However, to do this, it requires that spring-mock and junit become "compile" dependencies rather than "test" dependencies. Doesn't seem very clean. The only alternative I can think of is to create a "test" module that contains the base classes for each module. Unfortunately, the Base*TestCase classes in the "web" module depend on a lot of web-framework-specific classes and it might get ugly with the dependencies. I'm open to suggestions.
Advise from the Maven list:
http://www.nabble.com/How-do-I-include-base-tests-classes-in-main-JAR-tf2660727s177.html#a7421873 Option 1: Include Base*TestCase in sources and make any dependencies it requires optional Option 2: Use "test-jar" as Bryan suggested and include it in distribution and archetypes. I like #1. Hi,
I better like the option 2. This is because the Appfuse as a framework will preserve the way of Maven package structure which breaks a project into "modules" e.g. a standard directories for "test" and "source" instead of mixing altogether. It should be optional whether a user will depend on test source for a given module or not and each module should have it's own test-xxx-.jar. Sounds like a lot of requirements without a solution to them whether it fits to appfuse or not :-) but I think it will be more flexible in future if it could preserve the modularized way. There should be a solution and right now I'm not so creative but I will soon discuse this with my colleagues. // Tuncay Altun I went with option #1 for now - will refactor to #2 if a patch is provided and it proves to be a cleaner solution. ;-)
Nice for now, I hope some other or my team will find a better solution in future.
Good luck ! //tua This isn't quite as clean as I'd like it to be since users have to declare any testing frameworks they want to use in their pom.xml.
Options: 1. Keep the current setup and require users to declare junit, jmock, spring-mock, etc. for writing tests. 2. Try using the test-jar setup as described at http://maven.apache.org/guides/mini/guide-attached-tests.html. 3. Create a separate test module that has all its dependencies optional (so users don't get Struts sucked in on a JSF project and such). Make the standard testing frameworks part of the compile phase so they get sucked in. #3 seems like the most work from a project perspective and somewhat unclean from a code-organization perspective. Are we going to write tests for these tests? ;-) However, it would allow end users to get all the test dependencies by including appfuse-test (or something like that) in their dependencies. Thoughts? I'd like to get this resolved before the M1 release (hopefully w/in the next week or so). |
||||||||||||||||||||||||||||||||||||||||
Thx