gpt4 book ai didi

java - 为什么 maven-failsafe-plugin 不显示执行的 Restful 测试?

转载 作者:太空宇宙 更新时间:2023-11-04 10:11:23 28 4
gpt4 key购买 nike

我使用 Serenity 设置了一个基本项目,但在运行 mvn clean verify 时显示结果时遇到问题

[INFO] --- maven-failsafe-plugin:2.20:integration-test (default) @ functional-tests ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running starter.SmokeTestSuite
Feature: Booking

@Smoke
Scenario Outline: Book a reservation # src/test/resources/features/book/booking_creation.feature:4
Given an agent with role "ADMIN" has logged in

Examples:

@Smoke
Scenario Outline: Book a reservation # src/test/resources/features/book/booking_creation.feature:19
Started InternetExplorerDriver server (32-bit)
3.13.0.0
Listening on port 11642
Only local connections are allowed
Sep 10, 2018 7:50:29 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Given an agent with role "ADMIN" has logged in # LoginSteps.agent_has_logged_in(String)

1 Scenarios (1 passed)
1 Steps (1 passed)
0m18.568s

[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 19.681 s - in starter.SmokeTestSuite
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

以下是我从这个问题中得到的一些事实:

  • 未显示“SERENITY”和“TEST STARTED”ascii 图画,但显示“TEST FAILED”ascii 图画
  • 测试正在运行(正如您在日志中看到的,它显示通过了 1 个场景),问题是它没有显示执行的测试数量
  • 无论测试通过或失败,它都不会显示任何内容
  • 运行程序类是 runner/SmokeTestSuite.java

这是我的 pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>functional-tests</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

<name>functional tests</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<serenity.version>1.9.26</serenity.version>
<serenity.maven.version>1.9.26</serenity.maven.version>
<serenity.cucumber.version>1.9.8</serenity.cucumber.version>
<encoding>UTF-8</encoding>
<tags></tags>
<parallel.tests>4</parallel.tests>
<webdriver.base.url></webdriver.base.url>
</properties>

<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-junit</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay-webdriver</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-cucumber</artifactId>
<version>${serenity.cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.6.2</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.20</version>
<configuration>
<includes>
<include>**/*TestSuite.java</include>
</includes>
<!--
<systemPropertyVariables>
<webdriver.base.url>${webdriver.base.url}</webdriver.base.url>
</systemPropertyVariables>
-->
<parallel>classes</parallel>
<threadCount>${parallel.tests}</threadCount>
<forkCount>${parallel.tests}</forkCount>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.maven.version}</version>
<configuration>
<tags>${tags}</tags>
</configuration>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

非常感谢您的帮助,谢谢!

最佳答案

我在类似的项目中遇到了同样的问题。 Surefire 不计算 Serenity 测试结果的原因是因为 POM 包含 JUnit 和 TestNG Artifact 。 TestNG Artifact 是通过父 POM 添加的。

删除 TestNG 依赖项后,报告显示执行的测试数量。

关于java - 为什么 maven-failsafe-plugin 不显示执行的 Restful 测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52258481/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com