【发布时间】:2022-10-25 17:37:53
【问题描述】:
尝试使用小黄瓜、黄瓜和柏树进行自动化测试。我在 *.feature 文件中编写测试场景,在 *.js 文件中编写代码。
他想逐个模块地测试。首先测试的是登录模块,接下来是注册模块。
登录功能
Feature: Login page
Feature Login page will work depending on the user credentials.
Background:
Given A user opens a website to log in
Scenario: Success Login as Agent
When A user enters the username "agent"
And A user enters the password "pass!"
And A user clicks on the login button
Then The user was logged in as an Agent
Scenario: Success Login as Customer
When A user enters the username "customer"
And A user enters the password "pss123!"
And A user clicks on the login button
Then The user was logged in as an Customer
Scenario: Success Login as Admin
When A user enters the username "admin"
And A user enters the password "admin1"
And A user clicks on the login button
Then The user was logged in as an Admin
Scenario: Log in to the wrong user
When A user enters the username "1qazxsw23edc"
And A user enters the password "1qazxsw23edc"
And A user clicks on the login button
Then Error when logging in to the wrong user
注册功能
Feature: New user registration.
Feature is designed to test the operation of registration.
Background:
Given A user opens a website to register
Scenario: Correct registration of a new user
When User clicks on button to register
And A user enters the username "cypress_agent"
And A user enters the email "cypress_test@gmail.com"
And A user enters the first name "Cypress"
And A user enters the last name "Test"
And A user enters the password "zaq1@WSX"
And A user enters the password confirmation "zaq1@WSX"
And A user clicks on the submit button
Then TBA
当尝试触发步骤重复的任何功能文件时会出现问题,这是因为步骤“用户打开网站以登录”或“用户输入用户名 {string}”。
Error
Multiple matching step definitions for: A user enters the username "cypress_agent"
A user enters the username {string}
A user enters the username {string}
最简单的解决方案是更改名称。但是,有人告诉我,测试越深入,最终相同的名称就会重复。这个问题还有其他解决方案吗?例如。使 login.js 文件仅使用 login.feature 和相同的注册。除非您推荐其他解决方案。提前谢谢你和最好的问候。
【问题讨论】:
标签: javascript automated-tests cucumber cypress gherkin