[英]DropwizardAppRule and maven-failsafe-plugin
This is my DropwizardAppRule
in MyAppIT.java class: 这是我
DropwizardAppRule
在MyAppIT.java类:
@ClassRule
public static final DropwizardAppRule<MyConfiguration> RULE =
new DropwizardAppRule<>(MyApplication.class, YAML_PATH);
This would return the LocalPort
my local Dropwizard App is running on: 这将返回我的本地Dropwizard应用运行的
LocalPort
:
RULE.getLocalPort()
When running in IntelliJ
, it returns 9998
and all tests pass but when I do mvn clean install
or mvn verify
from the command line, it throws a NullPointerException
and I see a bunch of Connection refused
errors. 在
IntelliJ
运行时,它返回9998
并通过所有测试,但是当我从命令行执行mvn clean install
或mvn verify
,它将引发NullPointerException
并且我看到一堆Connection refused
错误。
ERROR! javax.ws.rs.ProcessingException: java.net.ConnectException: Connection refused
Here is my maven-failsafe-plugin
config: 这是我的
maven-failsafe-plugin
配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<includes>
<include>MyAppIT.java</include>
</includes>
<systemProperties>
<property>
<name>test.environment</name>
<value>${test.environment}</value>
</property>
</systemProperties>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
It seems as if the DropwizardAppRule
isn't even starting (since the port is null). 似乎
DropwizardAppRule
甚至没有启动(因为端口为null)。 What am I missing? 我想念什么?
I included MyAppIT.java to the maven-surefire-plugin
and it worked: 我将MyAppIT.java包含到了
maven-surefire-plugin
surefire maven-surefire-plugin
,它的工作原理是:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<includes>
<include>MyAppIT.java</include>
</includes>
</configuration>
</plugin>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.