Friday, August 21, 2009

Maven test resources

In a Maven project, it is recommended that you keep your test resources in src/test/resources, separate from src/main/resources. However, a lot of times, or most of the time, the resources are pretty much the same, such as service.xml, dao.xml, log4j.properties etc. When you work on a new DAO in TDD fashion, you would add the definition in src/test/dao.xml first and copy it to src/main/dao.xml once it works as expected. It becomes a hassle to maintain both places. I would say why not share the main resources with test. You can do it literally this way: tell test to use main as resouces.

<testResources>
<testResource>
<filtering>false</filtering>
<directory>src/mail/resources</directory>
</testResource>
</testResources>

No comments:

Post a Comment