0
這是我在MyAppIT.java類DropwizardAppRule
:DropwizardAppRule和Maven故障保護,插件
@ClassRule
public static final DropwizardAppRule<MyConfiguration> RULE =
new DropwizardAppRule<>(MyApplication.class, YAML_PATH);
這將返回LocalPort
我的本地Dropwizard應用程序運行於:
RULE.getLocalPort()
當運行IntelliJ
,它返回9998
並且所有測試都通過了,但是當我從命令行執行mvn clean install
或mvn verify
時,它會拋出NullPointerException
,我看到一堆Connection refused
錯誤。
ERROR! javax.ws.rs.ProcessingException: java.net.ConnectException: Connection refused
這裏是我的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>
它看來,如果DropwizardAppRule
甚至沒有開始(因爲端口爲空)。我錯過了什麼?