【发布时间】:2017-10-13 11:34:36
【问题描述】:
我正在开发我的第一个功能文件/selenium 项目。
我已经创建了一个特性文件和运行器类。
package cucumberpkg2;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions
(features="Features")
public class Runner {
}
Feature: Login screen
Scenario Outline: Successful login
Given User is on Login page
When User enters valid UserName and Password
And Clicks the login button
Then User landed on the home page
但每当我尝试将 TestRunner 类作为 JUnit 测试运行时,我都会收到错误消息:
在所选项目中找不到测试类。
【问题讨论】:
-
您还需要在@CucumberOptions 中将步骤定义所在的功能文件指定为
glue={"packagename.classname"},的位置 -
@kushal。
glue选项对于测试 Cucumber 项目绑定不是必需的。但是当你想测试完整的实现时,glue是强制性的:) 谢谢 -
@dev,我知道胶水有时不是强制性的,但我不明白你的说法:/
-
如果资源文件中的结构与 java 中的结构相同,则不需要胶水语句,否则需要它。