【问题标题】:maven-failsafe-plugin not running integration testsmaven-failsafe-plugin 未运行集成测试
【发布时间】:2019-05-08 03:39:22
【问题描述】:

我正在努力进行集成测试,但由于某种原因 ma​​ven-failsafe-plugin 没有运行。 以下是用于集成测试的配置文件。 测试类的名称是 AppSmokeTestIT.java。 @Test 正在用于测试。

<profiles>
    <profile>
        <id>default</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>${maven.war.version}</version>
                    <configuration>
                        <archive>
                            <manifest>
                                <addClasspath>true</addClasspath>
                            </manifest>
                        </archive>
                        <packagingExcludes>${package.excludes}</packagingExcludes>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
    <profile>
        <id>smoke-test</id>
        <build>
            <finalName>APP</finalName>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>${build.helper.maven.version}</version>
                    <executions>
                        <execution>
                            <id>reserve-network-port</id>
                            <goals>
                                <goal>reserve-network-port</goal>
                            </goals>
                            <phase>process-resources</phase>
                            <configuration>
                                <portNames>
                                    <portName>tomcat.http.port</portName>
                                </portNames>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>${tomcat.maven.version}</version>
                    <configuration>
                        <port>${tomcat.http.port}</port>
                        <path>/${project.build.finalName}</path>
                        <additionalConfigFilesDir>${basedir}/src/test/resources/tomcatconf</additionalConfigFilesDir>
                    </configuration>
                    <executions>
                        <execution>
                            <id>start-server</id>
                            <configuration>
                                <fork>true</fork>
                            </configuration>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>run</goal>h
                            </goals>
                        </execution>
                        <execution>
                            <id>stop-server</id>
                            <configuration>
                            </configuration>
                            <phase>post-integration-test</phase>
                            <goals>
                                <goal>shutdown</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>${maven.failsafe.version}</version>
                    <configuration>
                        <systemPropertyVariables>
                            <integration-test.url>${tomcat.local.host}${tomcat.http.port}/${project.build.finalName}/</integration-test.url>
                        </systemPropertyVariables>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>org.apache.maven.surefire</groupId>
                            <artifactId>surefire-junit47</artifactId>
                            <version>${maven.failsafe.version}</version>
                        </dependency>
                    </dependencies>
                    <executions>
                        <execution>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>${maven.war.version}</version>
                    <configuration>
                        <archive>
                            <manifest>
                                <addClasspath>true</addClasspath>
                            </manifest>
                        </archive>
                        <packagingExcludes>${package.excludes}</packagingExcludes>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

我查看了有关此问题的多个帖子,并且>完成了以下操作

我试过只在 build 标签中运行插件。

我试过添加

<includes>
    <include>**/*IT.java</include>
</includes>

我也尝试过运行 ma​​ven-failsafe-plugin 版本 2.18.1,因为我看到有人遇到此问题,建议它对他们有用。

【问题讨论】:

  • 你能在 Github 上做一个显示问题的示例项目吗……从这些 sn-ps 很难猜出真正的问题是什么……
  • 试试answer here。特别要注意插件配置。

标签: java maven junit maven-failsafe-plugin


【解决方案1】:

抱歉,各位,浪费了你们的时间。 昨天脑子里放了个屁,今天早上发现我在运行全新安装时没有选择所需的配置文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-11
    • 1970-01-01
    • 2019-08-31
    • 2011-12-09
    • 1970-01-01
    相关资源
    最近更新 更多