[英]Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test (default-test) on project testing: No tests were executed
When I run my maven build with当我运行我的 Maven 构建时
clean verify -U -fae -P TestExecutor -DcucumberTag=@full -Dheadless=true
I get following error我收到以下错误
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test (default-test) on project testing: No tests were executed! (Set -DfailIfNoTests=false to ignore this error.) -> [Help 1]
This is my pom.xml这是我的 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.xxx</groupId>
<artifactId>testing</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<cucumber.version>7.3.3</cucumber.version>
<selenium.version>4.1.4</selenium.version>
<awaitility.version>4.2.0</awaitility.version>
<assertj.version>3.22.0</assertj.version>
<commonsmodel.version>5.3.3</commonsmodel.version>
<maven.compiler.version>3.10.1</maven.compiler.version>
<maven.surefire.version>3.0.0-M5</maven.surefire.version>
<commons-lang3.version>3.12.0</commons-lang3.version>
<junit.jupiter.version>5.8.2</junit.jupiter.version>
</properties>
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit-platform-engine</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<version>1.8.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/net.jodah/failsafe -->
<dependency>
<groupId>net.jodah</groupId>
<artifactId>failsafe</artifactId>
<version>2.4.4</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>${awaitility.version}</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<configuration>
<skipTests>false</skipTests>
<testFailureIgnore>true</testFailureIgnore>
<includes>
<includes>**/TestExecutor.java</includes>
</includes>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>TestExecutor</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<configuration>
<skipTests>false</skipTests>
<testFailureIgnore>true</testFailureIgnore>
<test>
TestExecutor.java
</test>
<includes>
<includes>**/TestExecutor.java</includes>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
And this is my executor:这是我的执行人:
package com.xxx.tests;
import org.junit.platform.suite.api.ConfigurationParameter;
import org.junit.platform.suite.api.IncludeEngines;
import org.junit.platform.suite.api.SelectClasspathResource;
import org.junit.platform.suite.api.Suite;
import static io.cucumber.junit.platform.engine.Constants.FEATURES_PROPERTY_NAME;
import static io.cucumber.junit.platform.engine.Constants.FILTER_TAGS_PROPERTY_NAME;
import static io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME;
import static io.cucumber.junit.platform.engine.Constants.PLUGIN_PROPERTY_NAME;
@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("com/xxx")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "com.xxx")
@ConfigurationParameter(key = FILTER_TAGS_PROPERTY_NAME, value = "@full")
@ConfigurationParameter(key = FEATURES_PROPERTY_NAME, value = "web-testing/src/test/resources/features")
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "json:target/cucumber.json, html:target/cucumber.html")
public class TestExecutor {
}
but one way or another I just get this error while trying to run with the maven command, I need this to work for my tests to run on Jenkins.但是在尝试使用 maven 命令运行时,我会以一种或另一种方式遇到此错误,我需要它才能使我的测试在 Jenkins 上运行。
If I locally run the TestExecutor class within my IDE, every test tagged with @full runs properly.如果我在我的 IDE 中本地运行 TestExecutor 类,则带有 @full 标记的每个测试都可以正常运行。
Bit hard to say what the exact problem is.很难说确切的问题是什么。 You've not made a minimal reproducer.
您还没有制作最小的复制器。 Have a look at How to Ask .
看看如何提问。
However these are in conflict:然而,这些是冲突的:
@ConfigurationParameter(key = FEATURES_PROPERTY_NAME, value = "web-testing/src/test/resources/features")
This tells Cucumber to look for features in your features
package.这告诉 Cucumber 在你的
features
包中寻找功能。 Though it should only be used in combination with `mvn test -Dcucumber.features=....." to work around Maven's limited support for JUnit 5.虽然它只能与 `mvn test -Dcucumber.features=....." 结合使用,以解决 Maven 对 JUnit 5 的有限支持。
@SelectClasspathResource("com/xxx")
This is the way to tell Cucumber to look for features on the classpath.这是告诉 Cucumber 在类路径中查找特性的方法。 However, the previous annotation suggests they are in the
features
package, not com.xxx
.但是,前面的注释表明它们在
features
包中,而不是com.xxx
。
Another problem:另一个问题:
public class TestExecutor {
}
By convention test classes end with the Test
suffix. 按照惯例,测试类以
Test
后缀结尾。 . . Surefire understands this convention.
Surefire 理解这个约定。 However by naming things outside of this convention you now have to add additional configuration.
但是,通过在此约定之外命名事物,您现在必须添加其他配置。
This again makes your problem more complicated then it needs to be.这再次使您的问题变得比它需要的更复杂。
And given that you can run this class with IDEA but not surefire indicates the way you configures surefire may be the problem.并且鉴于您可以使用 IDEA 运行此类但 not surefire 表明您配置 surefire 的方式可能是问题所在。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.