这是MyAppIT.java类中的DropwizardAppRule
:
@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
甚至没有启动(因为端口为空)。我错过了什么?
答案 0 :(得分:0)
我将MyAppIT.java包含在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>