【问题标题】:DropwizardAppRule and maven-failsafe-pluginDropwizardAppRule 和 maven-failsafe-plugin
【发布时间】:2017-02-06 18:02:21
【问题描述】:

这是我在 MyAppIT.java 类中的DropwizardAppRule

@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 甚至没有启动(因为端口为空)。我错过了什么?

【问题讨论】:

    标签: java dropwizard maven-failsafe-plugin


    【解决方案1】:

    我将 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>
    

    【讨论】:

      猜你喜欢
      • 2012-08-30
      • 2013-05-23
      • 2012-09-18
      • 2012-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-08
      • 2011-07-30
      相关资源
      最近更新 更多