0
測試用例試圖實現:使用Maven在轉輪類配置Maven的不執行下轉輪類配置在黃瓜
運行黃瓜測試用例。
問題:
配置測試用例不被使用maven執行。
配置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>
和轉輪類是這樣
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{
}
當Maven測試或Maven安裝從Eclipse的執行,都沒有得到執行的測試用例但構建是成功的。
'**/helpers.RunCukesTest.java'看起來很奇怪,應該不是 '**/helpers/RunCukesTest.java'? – Tome
@Tome嘗試過**/* RunCukesTest.java。相同的結果 –
'helpers \ RunCukesTest'位於\ src \ test \ java文件夾層次結構內部嗎?默認情況下,maven應該選擇這個測試類,因爲它符合可接受的模式。 - http://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html – Grasshopper