Я настроил фреймворк Селен-огурец с помощью Junit.После добавления плагина cucumber-jvm -rallel и плагина maven-surefire прокомментировал операторы внутри @CucumberOptions, которые мы написали в файле TestRunnerTest.java. После такой настройки выполните CLI.Тогда мой тестовый скрипт не пройден.Но Бегунки создаются автоматически для файла объектов.
Файл POM показан ниже:
<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>selcuc</groupId>
<artifactId>DemoEurasia</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>CucumberParallel</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.cucumber>3.0.2</version.cucumber>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyy_MM_dd_HH_mm</maven.build.timestamp.format>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.14.0</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<!-- <dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<version>1.2.5</version>
<type>pom</type>
</dependency> -->
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-jvm-deps -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>gherkin</artifactId>
<version>2.12.2</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.1.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<executions>
<execution>
<id>acceptance-test</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<forkCount>2</forkCount>
<reuseForks>true</reuseForks>
<includes>
<include>**/*IT.class</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.temyers</groupId>
<artifactId>cucumber-jvm-parallel-plugin</artifactId>
<version>2.1.0</version>
<executions>
<execution>
<id>generateRunners</id>
<phase>validate</phase>
<goals>
<goal>generateRunners</goal>
</goals>
<configuration>
<glue>stepDefinition</glue>
<outputDirectory>target/generated-test-sources/cucumber</outputDirectory>
<featuresDirectory>src/test/resources/</featuresDirectory>
<cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>
<format>html</format>
<strict>true</strict>
<monochrome>true</monochrome>
<tags>"~@ignore"</tags>
<filterFeaturesByTags>true</filterFeaturesByTags>
</configuration>
</execution>
</executions>
TestRunnerTest.java показан ниже:
package testRunner;
@RunWith(Cucumber.class)
@CucumberOptions(
// features = "src/test/resources/1login.feature"
// , tags= {"@Login or @quickSearch"}
// , glue= {"stepDefinition"}
// , plugin = { "com.vimalselvam.cucumber.listener.ExtentCucumberFormatter:target/cucumber-reports/report.html"},
monochrome = true
public class TestRunnerTest {
public static WebDriver driver;
public static String timeStamp = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss a").format(new Date());
public static String browserName;
private static TestRunnerTest sharedInstance = new TestRunnerTest();
private TestRunnerTest() { }
public static TestRunnerTest getInstance() {
return sharedInstance;
}
@BeforeClass
public static void before() {
browserName = System.getProperty("browserName");
if(browserName==null)
{
browserName= "firefox";
}
if (browserName.equalsIgnoreCase("Chrome"))
{
System.setProperty("webdriver.chrome.driver", "E:\\ChromeDriverNew\\chromedriver.exe");
driver=new ChromeDriver();
}
else if (browserName.equalsIgnoreCase("Firefox"))
{
System.setProperty("webdriver.gecko.driver","E:\\geckoNew\\geckodriver.exe");
driver = new FirefoxDriver();
}
else {
System.out.println("Error Message----> "
+ "browser name not mentioned properly");
System.exit(0);
}
driver.manage().window().maximize();
// driver.manage().deleteAllCookies();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@AfterClass
public static void after() {
Runtime.getRuntime().addShutdownHook(new Thread()
{
public void run()
{
try {
Reporter.loadXMLConfig(new File("config/report.xml"));
Files.move(Paths.get("target/cucumber-reports"), Paths.get("target/cucumber-reports_ "+
LocalDateTime.now().format(DateTimeFormatter.ofPattern("L-d-YYYY h-m-s")) + "_" + browserName),
StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
e.printStackTrace();
}
}
});
if(driver!=null)
driver.quit();
}
}
Запустите это в CLI mvn test.Тогда получаю ошибку ниже:
@ DemoEurasia ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.901 s
[INFO] Finished at: 2018-09-27T15:11:17+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.temyers:cucumber-jvm-parallel-plugin:2
.1.0:generateRunners (generateRunners) on project DemoEurasia: Execution generat
eRunners of goal com.github.temyers:cucumber-jvm-parallel-
plugin:2.1.0:generateR
unners failed: Parser errors:
[ERROR] (17:3): inconsistent cell count within the table
Я не знаю, где я не прав.Было бы здорово, если бы вы, ребята, помогли мне.Не могли бы вы помочь мне, ребята.Заранее спасибо