統合テストのライフサイクル段階で、maven と maven-failsafe-plugin を使用して jetty を起動しています。次に、実行中の Web アプリケーションに対して多数の (*IT.java) junit テストを実行します。これは期待どおりに機能しています。
ただし、統合テストのためにテスト データベースに接続したいと考えています。そのURLを保存しています
${basedir}/src/test/resources/jdbc.properties
jetty プラグインが実行されると (jetty:run)、
${basedir}/src/main/resources/jdbc.propertes
代わりは。classesDirectoryプロパティを使用して jetty プラグインを再構成してみました
${project.build.testOutputDirectory}
しかし、test-classes ディレクトリには、実際にコンパイルされたプロジェクト クラスと、そこに保存されているリソースがありません。
${basedir}/src/main/resources
注:surefireはテストリソースをクラスパスに追加し、その後にメインリソースが続きます。両方で見つかったものは、クラスパスで最初に見つかったテストバージョンを使用します。
これを正しく設定する方法についてのアイデアはありますか?
ありがとう!
編集:
これに対処するために、jetty-plugin に構成プロパティがあるようです。
- testClassesDirectory : 生成されたテスト クラスを含むディレクトリ。
- useTestClasspath : true の場合、テストの依存関係がランタイム クラスパスの最初に配置されます。
残念ながら、それらは機能しません。
私の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>