Maven 没有执行任何 Cucumber 测试
Maven not executing any Cucumber tests
我无法使用 Maven 运行 在我的项目中进行任何 Cucumber 测试。但是,直接与 IntelliJ 中的测试进行交互是没有问题的。
Pom.xml
<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>cucumber</groupId>
<artifactId>cucumber-java-skeleton</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<name>Cucumber-Java Skeleton</name>
<properties>
<junit-jupiter.version>5.7.0</junit-jupiter.version>
<maven-surefire-plugin.version>2.22.0</maven-surefire-plugin.version>
<cucumber.version>6.8.0</cucumber.version>
<java.version>1.8</java.version>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.source>${java.version}</maven.compiler.source>
<project.encoding>UTF-8</project.encoding>
<project.build.sourceEncoding>${project.encoding}</project.build.sourceEncoding>
<project.reporting.outputEncoding>${project.encoding}</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit-platform-engine</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
</plugin>
</plugins>
</build>
</project>
CucumberTestRunnerClass
package io.cucumber.skeleton;
import io.cucumber.junit.platform.engine.Cucumber;
@Cucumber
public class CucumberTestRunner {
// See:
// https://github.com/cucumber/cucumber-jvm/issues/1149
// https://github.com/cucumber/cucumber-jvm/tree/master/junit-platform-engine
}
在 StepDefinitions Class 和特征文件中只是任意 1 + 1 = 2 个断言来初步证明这个概念。
当我执行./mvnw clean install
时,这是输出
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< cucumber:cucumber-java-skeleton >-------------------
[INFO] Building Cucumber-Java Skeleton 0.0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ cucumber-java-skeleton ---
[INFO] Deleting /Users/IdeaProjects/cucumber-java-skeleton/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ cucumber-java-skeleton ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/IdeaProjects/cucumber-java-skeleton/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ cucumber-java-skeleton ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ cucumber-java-skeleton ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ cucumber-java-skeleton ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /Users/IdeaProjects/cucumber-java-skeleton/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.0:test (default-test) @ cucumber-java-skeleton ---
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ cucumber-java-skeleton ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: /Users/IdeaProjects/cucumber-java-skeleton/target/cucumber-java-skeleton-0.0.1.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ cucumber-java-skeleton ---
[INFO] Installing /Users/IdeaProjects/cucumber-java-skeleton/target/cucumber-java-skeleton-0.0.1.jar to /Users/.m2/repository/cucumber/cucumber-java-skeleton/0.0.1/cucumber-java-skeleton-0.0.1.jar
[INFO] Installing /Users/IdeaProjects/cucumber-java-skeleton/pom.xml to /Users/.m2/repository/cucumber/cucumber-java-skeleton/0.0.1/cucumber-java-skeleton-0.0.1.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.618 s
[INFO] Finished at: 2020-10-01T13:17:51+01:00
[INFO] ------------------------------------------------------------------------
如有任何帮助,我们将不胜感激。
默认情况下,Maven (surefire) 只运行以 Test
.
结尾的测试 类
将 CucumberTestRunner
重命名为例如RunCucumberTest
,或配置 surefire 以寻找不同的模式。
我无法使用 Maven 运行 在我的项目中进行任何 Cucumber 测试。但是,直接与 IntelliJ 中的测试进行交互是没有问题的。
Pom.xml
<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>cucumber</groupId>
<artifactId>cucumber-java-skeleton</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<name>Cucumber-Java Skeleton</name>
<properties>
<junit-jupiter.version>5.7.0</junit-jupiter.version>
<maven-surefire-plugin.version>2.22.0</maven-surefire-plugin.version>
<cucumber.version>6.8.0</cucumber.version>
<java.version>1.8</java.version>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.source>${java.version}</maven.compiler.source>
<project.encoding>UTF-8</project.encoding>
<project.build.sourceEncoding>${project.encoding}</project.build.sourceEncoding>
<project.reporting.outputEncoding>${project.encoding}</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit-platform-engine</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
</plugin>
</plugins>
</build>
</project>
CucumberTestRunnerClass
package io.cucumber.skeleton;
import io.cucumber.junit.platform.engine.Cucumber;
@Cucumber
public class CucumberTestRunner {
// See:
// https://github.com/cucumber/cucumber-jvm/issues/1149
// https://github.com/cucumber/cucumber-jvm/tree/master/junit-platform-engine
}
在 StepDefinitions Class 和特征文件中只是任意 1 + 1 = 2 个断言来初步证明这个概念。
当我执行./mvnw clean install
时,这是输出
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< cucumber:cucumber-java-skeleton >-------------------
[INFO] Building Cucumber-Java Skeleton 0.0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ cucumber-java-skeleton ---
[INFO] Deleting /Users/IdeaProjects/cucumber-java-skeleton/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ cucumber-java-skeleton ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/IdeaProjects/cucumber-java-skeleton/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ cucumber-java-skeleton ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ cucumber-java-skeleton ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ cucumber-java-skeleton ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /Users/IdeaProjects/cucumber-java-skeleton/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.0:test (default-test) @ cucumber-java-skeleton ---
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ cucumber-java-skeleton ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: /Users/IdeaProjects/cucumber-java-skeleton/target/cucumber-java-skeleton-0.0.1.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ cucumber-java-skeleton ---
[INFO] Installing /Users/IdeaProjects/cucumber-java-skeleton/target/cucumber-java-skeleton-0.0.1.jar to /Users/.m2/repository/cucumber/cucumber-java-skeleton/0.0.1/cucumber-java-skeleton-0.0.1.jar
[INFO] Installing /Users/IdeaProjects/cucumber-java-skeleton/pom.xml to /Users/.m2/repository/cucumber/cucumber-java-skeleton/0.0.1/cucumber-java-skeleton-0.0.1.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.618 s
[INFO] Finished at: 2020-10-01T13:17:51+01:00
[INFO] ------------------------------------------------------------------------
如有任何帮助,我们将不胜感激。
默认情况下,Maven (surefire) 只运行以 Test
.
将 CucumberTestRunner
重命名为例如RunCucumberTest
,或配置 surefire 以寻找不同的模式。