当给定的状态有多个验证时,如何编写Gherkin方案?

问题描述 投票:0回答:1

我是黄瓜-小黄瓜世界的新手。我正试图写一个功能文件,我计划测试一个有很多静态内容(比如说100个部分)的静态网页。我计划测试一个有很多静态内容(比如说100个部分)的静态网页,我需要验证这些内容。理想的情况是,如果我根据我对小黄瓜的理解开始编写,它看起来像下面。

场景:测试参与页面内容

鉴于我是一个有>10000余额的用户。

当我登陆到我的订婚页面时

那么section1应该正确显示

而section2应该正确显示

而section3应该正确显示

而第4节应该正确显示

诸如此类------

而section100应该正确显示。

这绝对是看起来很丑。我怎么能把这个分成多个场景.我在测试一切,一旦我在那个页面上。我在页面上没有做任何活动。一旦我降落,我只需要验证所有的部分。

先谢谢你

cucumber cucumber-jvm gherkin cucumberjs
1个回答
1
投票

有很多方法可以做到这一点,但假设各部分共享元素和断言,方案大纲可能是你最好的选择。

Scenario Outline: Verify the display of all sections on the Engagement Page
Given I am a user with >10000 balance
When I land of Engagement Page
Then the header of <section> should read "<headerText>"
And the icon of <section> should be displayed
And the body of <section> should read "<bodyText>"

Examples:
  | section   | headerText         | bodyText        |
  | Section 1 | This is Header #1  | This is Body #1 |
  | Section 2 | Header Text of #2  | Body Text of #2 |
... etc

如果各部分的结构是独特的,你就面临着为每个部分写一个方案(或更多,取决于你的风格--我个人不喜欢在一个案例中出现多个断言)。

比如说: section1 有一个头、图标和正文,你最终会有以下三种情况。

Scenario: Verify display of header in Section 1
Given I am a user with >10000 balance
When I land of Engagement Page
Then the header of Section 1 should read "text"

Scenario: Verify display of icon in Section 1
Given I am a user with >10000 balance
When I land of Engagement Page
Then the icon of Section 1 should be displayed

Scenario: Verify display of body text in Section 1
Given I am a user with >10000 balance
When I land of Engagement Page
Then the body of Section 1 should read "text"

如果你对每个测试的多个断言都没意见的话,

Scenario: Verify display of Section 1
Given I am a user with >10000 balance
When I land of Engagement Page
Then the header of Section 1 should read "text"
And the icon of Section 1 should be displayed
And the body of Section 1 should read "text"
© www.soinside.com 2019 - 2024. All rights reserved.