0
我是Selenium Cucumber的新手,尝试使用Eclipse设置基本的Selenium Cucumber JVM,但是当我将Testrunner作为JUnit运行时,注释缺失,我需要手动在步骤中添加测试步骤定义。下面是我的特征& JUnit测试转轮Selenium - Cucument JUnit Test Runner - 没有得到注释
Feature: Gmail Login
@Scenario1
Scenario: User logs into GMail
Given Open Browser
When Enter gmail link
Then Enter login details
TestRunner.java
package cucumberTest;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(features = "C:\\XXXX-PATH\\Feature"
,glue={"stepDefinition"},
tags={"@Scenario1"},
monochrome=true
)
public class TestRunner {
}
当我执行TestRunner.java
作为JUnit中,段缺少注释,因此步骤定义需要手动写入 1方案(1未定义) 4步骤(4未定义) 可以实现失踪与下面的代码片段步骤:
Given("^Open Browser$",() -> {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
});
When("^Enter gmail link$",() -> {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
});
能有人帮我
<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>cucmber_test</groupId>
<artifactId>cucmber_test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<fork>true</fork>
<executable>C:\Program Files\Java\jdk1.8.0_111\bin\javac.exe</executable>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.47.1</version>
</dependency>
</dependencies>
</project>
那么最近你遇到的实际/实际问题/错误/困难是什么? 'JUnit'的'annotations'被Cucumber'特征'文件中的特征描述所取代。感谢 – DebanjanB
您需要在stepDefinition类文件中定义@given和“@when”方法;通过复制建议的确切语法 – kushal
感谢您的回应,我没有得到testrunner中建议的准确语法,@given没有创建,只有给定创建,因此我需要在StepDefinition中手动添加@语法。猜猜我缺少任何版本 – Gayathri