[英]Maven not executing the test cases configured under runner class in cucumber
Trying to Achieve: 尝试实现:
Run cucumber test cases configured in runner class using Maven. 使用Maven运行在Runner类中配置的黄瓜测试用例。
Issue: 问题:
Configured test cases are not being executed using maven. 尚未使用maven执行已配置的测试用例。
Configured pom.xml file: 配置的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>simplify360Cucumber</groupId>
<artifactId>s360UIAutomation</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<name>Cucumber-JVM template</name>
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-testng</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<version>1.2.5</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<version>2.24</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>3.7.0</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.0.6</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.16</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.16</version>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.8.0</version>
</dependency>
<!-- <dependency> <groupId>org.apache.maven.surefire</groupId> <artifactId>surefire-junit</artifactId>
<version>2.6</version> </dependency> -->
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<includes>
<include>**/helpers.RunCukesTest.java</include>
</includes>
<!-- <excludes> <exclude>**/*RunCukesTest.java</exclude> </excludes> -->
</configuration>
<!-- <dependencies> <dependency> <groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit</artifactId> <version>2.6</version> </dependency>
</dependencies> -->
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
And the runner class is like this 跑步者班是这样的
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(
features = {"classpath:features"},
plugin = {"pretty", "html:target/cucumber-html-report","json:target/cucumber.json"},
tags = {"@tag1"},
glue={"helpers","stepDefinitions"},
// dryRun = true,
monochrome = true
)
public class RunCukesTest{
}
When maven test or maven install are executed from eclipse, test cases are not getting executed but the build is successfull. 当从Eclipse执行maven测试或maven安装时,测试用例没有得到执行,但是构建成功。
import org.apache.log4j.Logger;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(plugin = { "pretty", "json:target/Cucumber-report/cucumber.json" },
features = { "src/test/resources/com/testcases/testsuite" })
public final class CucumberCommandLineTest {
private CucumberCommandLineTest() {
}
static final Logger LOGGER = Logger.getLogger(CucumberCommandLineTest.class.getName());
}
This seems to work for me for running at the CLI : 这对于我在CLI上运行似乎很有效:
C:\Tools\jdk1.7.0_79\bin\java" -cp lib\*;target\62110_Automation_KW_Smoke_Test-1.0.0.0-jar-with-dependencies.jar cucumber.api.cli.Main --glue com.gm.testcases .\src\test\resources\com\testcases\testsuite --tags @TC_185826,@TC_185824 --plugin pretty
in src/main/java and when doing maven clean:install through Eclipse m2e plugin. 在src / main / java中,以及在执行maven clean时:通过Eclipse m2e插件安装。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.