首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Maven验证不执行带故障安全的Cucumber-Serenity集成测试

Maven验证不执行带故障安全的Cucumber-Serenity集成测试
EN

Stack Overflow用户
提问于 2021-06-06 13:13:03
回答 1查看 596关注 0票数 0

我的项目中有低于POM的项目。

代码语言:javascript
复制
mvn clean verify -P it

POM:

代码语言:javascript
复制
 <build>
        <pluginManagement>
            <plugins>
              .....
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven-plugin.version}</version>
                    <configuration>
                        <skipTests>false</skipTests>
                        <excludes>
                            <exclude>**/*CucumberTests.java</exclude>
                            <exclude>**/IT*.java</exclude>
                        </excludes>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>${maven-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>integration-tests</id>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                            <configuration>
                                <skipTests>false</skipTests>
                                <testFailureIgnore>true</testFailureIgnore>
                                <excludes>
                                    <exclude>none</exclude>
                                </excludes>
                                <includes>
                                    <include>**/*CucumberTests.java</include>
                                    <include>**/*IT.java</include>
                                </includes>
                                <systemPropertyVariables>
                                    <it.server.port>${random.http.port}</it.server.port>
                                    <it.jmx.port>${random.jmx.port}</it.jmx.port>
                                </systemPropertyVariables>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>1.5.9.RELEASE</version>
                <executions>
                    <execution>
                        <id>pre-integration-test</id>
                        <goals>
                            <goal>start</goal>
                        </goals>
                        <configuration>
                            <skip>false</skip>
                            <wait>2000</wait>
                            <!-- Max retry count -->
                            <maxAttempts>180</maxAttempts>
                            <jmxPort>${random.jmx.port}</jmxPort>
                            <arguments>
                                <argument>--server.port=${random.http.port}</argument>
                                <argument>--spring.profiles.active=${spring.profile}</argument>
                            </arguments>
                            <jvmArguments>
                                -Djava.security.egd=file:///dev/urandom
                            </jvmArguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>post-integration-test</id>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                        <configuration>
                            <skip>false</skip>
                            <jmxPort>${random.jmx.port}</jmxPort>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
       ...
        </plugin>
        </plugins>
    </build>

考试班:

代码语言:javascript
复制
import org.junit.runner.RunWith;

import io.cucumber.junit.CucumberOptions;
import net.serenitybdd.cucumber.CucumberWithSerenity;

@RunWith(CucumberWithSerenity.class)
@CucumberOptions(
    plugin = {"pretty"},
    glue = {"my.stepdefinitions"},
    tags = {"@Demo"},
    features = "src/it/resources/features/"
)

public class MicroServiceCucumberTests {
}

路径:src/it/java

基本上,它触发确定性触发,然后启动应用程序,然后只停留在上,而不执行 maven-failsafe-plugin:2.21.0:integration-test (integration-tests)

目前正在使用以下版本:

代码语言:javascript
复制
<serenity.plugin.version>2.4.34</serenity.plugin.version>
<serenity.version>2.4.34</serenity.version>
<serenity.cucumber.version>2.4.34</serenity.cucumber.version>
<cucumber.version>6.10.4</cucumber.version>
<maven-plugin.version>3.0.0-M5</maven-plugin.version>
<java.version>1.8</java.version>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-06-23 01:56:57

在深入挖掘日志之后,我注意到,app没有正确启动,只停留在下面的日志中

代码语言:javascript
复制
DEBUG] Application argument(s): --server.port=54110 --spring.profiles.active=it
[DEBUG] Connecting to local MBeanServer at port 54111
[DEBUG] Waiting for spring application to start...
[DEBUG] MBean server at port 54111 is not up yet...
[DEBUG] Spring application is not ready yet, waiting 2000ms (attempt 1)
[DEBUG] MBean server at port 54111 is not up yet...
[DEBUG] Spring application is not ready yet, waiting 2000ms (attempt 2)

这个解决方案对我有效,https://stackoverflow.com/a/65952986/2303693

在POM中添加下面的spring-启动-maven-插件完成了这一任务。

代码语言:javascript
复制
 <configuration>
     <fork>false</fork>
  </configuration>

然而,相同的代码在iOS机器中工作,没有上面的修复。此外,还不清楚是什么导致了Windows中的问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67859521

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档