【发布时间】:2016-08-21 19:05:29
【问题描述】:
我正在编写 dropwizard 应用程序,但我坚持使用集成测试。我试图在 maven 的 pre-integration-test 阶段启动服务器,而不是在 post-integration-test 阶段停止它,但问题是我在使用 maven-exec 插件时丢失了 java 线程。
配置如下:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>create-and-run-dropwizard-test-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<arguments>
<argument>-jar</argument>
<argument>target/my-server.jar</argument>
<argument>server</argument>
<argument>test-config.yml</argument>
</arguments>
</configuration>
</plugin>
使用它,maven 会一直运行到pre-integration-test 阶段,然后在同一个线程中启动服务器。无论如何,我可以将其作为 bash 脚本运行,而不是使用 kill -9 命令停止它,但此解决方案与平台无关。
还有其他方法可以进行集成测试吗? 附言我正在使用 dropwizard v0.7.0-SNAPSHOT。
【问题讨论】:
-
您是否尝试过使用
java目标? -
我不确定如何使用 java 目标设置此参数。无论如何,我以后如何杀死该进程?
标签: java maven integration-testing dropwizard