【发布时间】:2018-06-23 23:43:53
【问题描述】:
我在 Feature 文件中有一些场景具有可重复的步骤(“我在登录表单上”和“单击登录按钮”)。测试失败,错误为 Duplicate step definitions in Steps.LoginSteps。
是否有可能以某种方式重用重复的步骤?
Feature: LoginFeature
Scenario: Login with valid username and password
Given I am on Login form
And I enter valid username and password
And click on login button
Then I should see the main page
Scenario: Login with invalid username and password
Given I am on Login form
And I enter invalid email username and password
And click on login button
When modal error is displayed
Then click on Ok button
And I should see the login form
【问题讨论】:
-
您是否为“我正在登录表单”创建了两个具有相同模式匹配的方法?可以添加相关的步骤定义吗?
-
没错,Steps定义文件也包含重复的方法。我已经删除了 Steps 定义文件中的重复方法,现在可以正常工作了!谢谢
标签: java cucumber gherkin cucumber-java