zxuanzi 2011-11-01
1.需求:
2.思路
集成测试时会通过maven-jetty-plugin启动jetty,这时jetty运行的war需要到src/test/resources下读取db配置文件
3.难点
另外install无法只skip集成测试,它只允许skipTest,导致单元测试和集成测试都skip
4.解决方案
<!-- maven-jetty-plugin增加配置useTestClasspath --> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> <version>6.1.26</version> <configuration> <scanIntervalSeconds>10</scanIntervalSeconds> <stopKey>stop-jetty-for-it</stopKey> <stopPort>9999</stopPort> <connectors> <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> <port>8888</port> <maxIdleTime>60000</maxIdleTime> </connector> </connectors> </configuration> <executions> <execution> <id>start-jetty</id> <phase>pre-integration-test</phase> <goals> <goal>run</goal> </goals> <configuration> <scanIntervalSeconds>0</scanIntervalSeconds> <daemon>true</daemon> <reload>manual</reload> <!-- 使得集成测试使用src/test/resources的配置 --> <useTestClasspath>true</useTestClasspath> </configuration> </execution> <execution> <id>stop-jetty</id> <phase>post-integration-test</phase> <goals> <goal>stop</goal> </goals> </execution> </executions> </plugin>
5.关于maven-jetty-plugin