2017-02-06 110 views
0

這是我在MyAppIT.java類DropwizardAppRuleDropwizardAppRule和Maven故障保護,插件

@ClassRule 
public static final DropwizardAppRule<MyConfiguration> RULE = 
     new DropwizardAppRule<>(MyApplication.class, YAML_PATH); 

這將返回LocalPort我的本地Dropwizard應用程序運行於:

RULE.getLocalPort() 

當運行IntelliJ,它返回9998並且所有測試都通過了,但是當我從命令行執行mvn clean installmvn 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

我包括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>