[英]Cucumber tests not executing when running maven test
I have a cucumber project. 我有一个黄瓜项目。 When I right click on the RunnerTest class and "Run "RunnerTest" all the features from the feature file starts running. All tests pass.
当我右键单击RunnerTest类并“运行“ RunnerTest”时,功能文件中的所有功能开始运行。所有测试均通过。
My RunnerTest.class 我的RunnerTest.class
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import java.sql.SQLException;
import lombok.extern.log4j.Log4j2;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(
features = {"classpath:foo.feature"},
glue = "com.foo.foobar.StepDefinitions",
plugin = {"json:target/cucumber-report/cucumber.json"},
monochrome = true,
strict = true
//,dryRun = true
)
@Log4j2
public class RunnerTest {}
But when I try to run mvn test or mvn clean install features are not running. 但是,当我尝试运行mvn test或mvn时,干净安装功能未运行。 This is the output.
这是输出。
Running TestSuite Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@515f550a Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.895 sec 运行TestSuite使用以下方法配置TestNG:org.apache.maven.surefire.testng.conf.TestNG652Configurator@515f550a测试运行:0,失败:0,错误:0,跳过:0,经过时间:0.895秒
Results : 结果:
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 测试运行:0,失败:0,错误:0,跳过:0
These are my POM dependencies 这些是我的POM依赖项
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-jvm</artifactId>
<version>3.0.0</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>gherkin</artifactId>
<version>4.1.3</version>
</dependency>
<!--<dependency>-->
<!--<groupId>junit</groupId>-->
<!--<artifactId>junit</artifactId>-->
<!--<version>4.12</version>-->
<!--</dependency>-->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.6</version>
<scope>test</scope>
</dependency>
I have tried to add mvn surefire plugin and including my RunnerTest Class there. 我试图添加mvn surefire插件,并在其中包括我的RunnerTest类。
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<includes>
<include>RunnerTest.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
But that does not work either 但这也不起作用
Known Issue : If you keep Junit & TestNG both dependencies in parallel, Then TestNG dependency causes Surefire to ignore JUnit wrapper class. 已知问题:如果并行保持Junit和TestNG两个依赖关系,则TestNG依赖关系将导致Surefire忽略JUnit包装器类。
Solution : There could be multiple way of handling this like we can define 2 execution, each for TestNG & JUnit and disable one as per your need. 解决方案:可能有多种处理方式,例如我们可以定义2个执行,每种分别用于TestNG和JUnit,并根据需要禁用一个。
Can you please try with this : Please remove any direct/indirect TestNG dependency. 您能尝试一下吗:请删除任何直接/间接的TestNG依赖项。
org.testng testng 6.14.3 test org.testng testng 6.14.3测试
And try to add below one - 并尝试添加以下一个-
io.cucumber cucumber-testng 3.0.0 io。黄瓜黄瓜试3.0.0
Also, I would suggest you one more thing to keep your pom.xml clean. 另外,我建议您再做一件事以保持pom.xml的干净。
Key Point : 关键点 :
You shall remove cucumber-core, cucumber-java, cucumber-jvm, cucumber-jvm-deps, gherkin as these are transitive dependencies which would get added by Maven when you add below direct (main) dependencies. 您应删除小黄瓜芯,小黄瓜java,小黄瓜jvm,小黄瓜jvm-deps,小黄瓜,因为它们是传递性依赖,当您添加以下直接(主)依赖时,Maven会添加这些依赖。 Just add below 2 and one for testng shared above.
只需添加下面的2和上面共享的testng一个。
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>3.0.0</version>
</dependency>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.