当前位置: 首页 > 知识库问答 >
问题:

Gherkin-在场景之间保持状态

谭桐
2023-03-14

尽管我已经编写单元测试20多年了,但我对Gherkin还是新手,并且还被赋予了为一个。feature文件实现故事的任务,该文件可以简化为以下内容:

Scenario: a
    Given that the app is open
    When I open a certain dialog
    Then it has a thing somewhere

Scenario: b
    Given that the dialog from 'a' is open...

# Imagine here a long chain of scenarios, each depending on the previous

Scenario: n
    Given that the previous 'n' steps have all completed....

也就是说,一个很长很长的场景链,每个场景都依赖于由其前身配置的系统状态。

我在JavaScript中运行Cucumber。

共有1个答案

欧金鹏
2023-03-14

第一件事在先,警告:

对于大多数测试(我所说的大多数是指99.9%的时间),您不应该继续以前的场景,因为如果一个场景在您的特性中失败了,更多的场景将会崩溃,因为您试图将它们连接在一起。

接着我的回答:

    null
Background:
  Given that the app is open
  When I open a certain dialog
  Then it has a thing somewhere

Scenario: a
  Given that the dialog from 'a' is open...

对于第二个:

Scenario: a
    Given that the app is open
    When I open a certain dialog
    Then it has a thing somewhere

Scenario: b
    Given I have opened the dialogue from a
    And the '<DialogFromA>' dialog is open...
 类似资料:
  • 有没有可能用gherkin写一个场景大纲,其中有一个断言步骤,而不是在所有的例子中都需要? null 有没有更好的写法?

  • 我创建了一个游戏,我想给它添加一个开始屏幕,我使用FXML添加了它,还添加了两个按钮(开始和退出)。 按下开始按钮后,我希望游戏加载场景并切换到游戏开始。我对如何做有一个粗略的想法,但我有点挣扎,因为我的SampleController类不知道如何启动游戏等,因为所有代码(以及加载初始开始菜单的代码)都在我的主类中,所以我尝试了这样的事情: 我尝试使用一个函数来切换场景,但它不起作用,也试图使用获

  • 我在class1中创建了一个场景,然后在Class2中创建了一个scene2。如何在两者之间切换? 这是第二节课,我有另一个场景。

  • 目前,我创建了一个如下所示的特性文件(在这个示例中,我已经用...删除了数据):

  • 接口说明 保存场景 如需调用,请访问 开发者文档 来查看详细的接口使用说明 该接口仅开放给已获取SDK的开发者 API地址 POST /wish3dearth/api/scene/v1.0.0/saveScene 是否需要登录 是 请求字段说明 参数 类型 请求类型 是否必须 说明 token string header 是 当前登录用户的TOKEN sceneId string formData

  • 接口说明 保存场景 如需调用,请访问 开发者文档 来查看详细的接口使用说明 该接口仅开放给已获取SDK的开发者 如开启https功能,请求地址的协议应改为https,如:https://www.example.com/wish3dearth/api/access/v1.0.0/getLicenseInfo API地址 POST /wish3dearth/api/scene/v1.0.0/saveS