java - How to: Run maven integration tests against a test environment (database) -
i'm using maven , maven-failsafe-plugin start jetty during integration-test lifecycle phase. execute number of (*it.java) junit tests against running webapp. working expected.
however, connect test database integration tests. storing url in
${basedir}/src/test/resources/jdbc.properties
when jetty plugin runs (jetty:run), uses
${basedir}/src/main/resources/jdbc.propertes
instead. tried reconfiguring jetty plugin via classesdirectory property use
${project.build.testoutputdirectory}
but test-classes directory missing actual compiled project classes, resources stored in
${basedir}/src/main/resources
note: surefire adds test resources classpath, followed main resources, such found in both use test version because found first in classpath.
any ideas on how set correctly?
thanks!
edit:
well, seems there configuration properties on jetty-plugin deal this:
- testclassesdirectory : directory containing generated test classes.
- usetestclasspath : if true, , dependencies of test put first on runtime classpath.
unfortunately, don't work.
here relevant portion of pom.xml:
<testresources> <testresource> <filtering>true</filtering> <directory>src/test/resources</directory> </testresource> </testresources> <plugins> <plugin> <groupid>org.mortbay.jetty</groupid> <artifactid>maven-jetty-plugin</artifactid> <version>6.1.26</version> <configuration> <contextpath>/</contextpath> <stopport>8005</stopport> <stopkey>stop</stopkey> </configuration> <executions> <execution> <id>start-jetty</id> <phase>pre-integration-test</phase> <goals> <goal>run</goal> </goals> <configuration> <daemon>true</daemon> <usetestclasspath>true</usetestclasspath> <testclassesdirectory>${project.build.testoutputdirectory}</testclassesdirectory> </configuration> </execution> <execution> <id>stop-jetty</id> <phase>post-integration-test</phase> <goals> <goal>stop</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactid>maven-failsafe-plugin</artifactid> <version>2.6</version> <executions> <execution> <goals> <goal>integration-test</goal> <goal>verify</goal> </goals> </execution> </executions> <configuration> <usefile>false</usefile> </configuration> </plugin>
i have same problem, , solved using custom web.xml (jettyweb.xml) see maven configuarion
<build> <plugins> <plugin> <groupid>org.mortbay.jetty</groupid> <artifactid>maven-jetty-plugin</artifactid> <configuration> <overridewebxml>./src/main/webapp/web-inf/jettyweb.xml</overridewebxml> <scanintervalseconds>3</scanintervalseconds> </configuration> <dependencies> </dependencies> </plugin> </plugins> </build>
in case use configuration use other spring configuration manage transactions. strategy used use other property files.
my original web.xml has spring configuration
<context-param> <param-name>contextconfiglocation</param-name> <param-value> /web-inf/spring-hibernate.xml, /web-inf/spring-services.xml </param-value> </context-param>
my jettyweb.xml has spring configuration
<context-param> <param-name>contextconfiglocation</param-name> <param-value> /web-inf/spring-hibernate-jetty.xml, /web-inf/spring-services.xml </param-value> </context-param>
this should put on correct path
Comments
Post a Comment