场景大纲下具有不同数量项的数据表,在Cucumber中有多个示例。可能吗?

场景大纲下具有不同数量项的数据表,在Cucumber中有多个示例。可能吗?,cucumber,scenarios,Cucumber,Scenarios,我在我的应用程序中有四个非常相似的部分,我正试图使用场景大纲将足够相似的测试组合在一起,以便于维护,并将它们所处的部分(页面)作为参数。然而,这些单独编写的测试在其datatable下包含不同数量的项(但仍然执行相同的断言),因此我想知道是否有可能为每个示例部分使用不同的datatable 比如: Scenario Outline: Verify that the user is able to see the details recorded on the note And I naviga

我在我的应用程序中有四个非常相似的部分,我正试图使用场景大纲将足够相似的测试组合在一起,以便于维护,并将它们所处的部分(页面)作为参数。然而,这些单独编写的测试在其datatable下包含不同数量的项(但仍然执行相同的断言),因此我想知道是否有可能为每个示例部分使用不同的datatable

比如:

Scenario Outline: Verify that the user is able to see the details recorded on the note 
And I navigate to the "<page>" screen
Then the following items are displayed for their respective fields

@page1
Examples:
Then the following items are displayed for their respective fields
  | field   | text       |
  | title   | My title   |
  | history | My history |

@page2
Then the following items are displayed for their respective fields
  | field   | text       |
  | comment | My comment |
  | details | My details |
  | status  | My status  |
Scenario Outline: Verify that the user is able to see the details recorded on the note 
Then the following items are displayed for their respective fields

@page1
Examples:
Then the following items are displayed for their respective fields
  | field   | text  | item1 | item2 |
我也不能有这样的东西:

Scenario Outline: Verify that the user is able to see the details recorded on the note 
And I navigate to the "<page>" screen
Then the following items are displayed for their respective fields

@page1
Examples:
Then the following items are displayed for their respective fields
  | field   | text       |
  | title   | My title   |
  | history | My history |

@page2
Then the following items are displayed for their respective fields
  | field   | text       |
  | comment | My comment |
  | details | My details |
  | status  | My status  |
Scenario Outline: Verify that the user is able to see the details recorded on the note 
Then the following items are displayed for their respective fields

@page1
Examples:
Then the following items are displayed for their respective fields
  | field   | text  | item1 | item2 |
因为这些数量会发生变化,所以我可以在一个页面上测试三个项目,但在另一个页面上测试两个项目,在另一个页面上测试四个项目

我希望我对自己想要实现的目标已经足够清楚了


非常感谢。

您编写的场景非常类似于描述每个步骤的测试脚本。这对小黄瓜不起作用。它不是一种编程语言,试图用它编程是很困难的。尝试写下应用程序的行为

Scenario: Details of the note can be seen on page1 and page2
  Given Claire has created a note
   | property | value    | 
   | title    | My title |
   | ect ....
  When she views the notes details
  Then on "Notes Overview" she can see:
   | field   | text       |
   | title   | My title   |
   | history | My history |
  And on "Note Details" she can see:
   | field   | text       |
   | comment | My comment |
   | details | My details |
   | status  | My status  |

在给定的
步骤中,创建一个名为Claire的用户,打开应用程序,然后创建便笺。在
When
步骤中导航到正确的页面,然后在
步骤中检查在正确的字段中是否可以看到正确的内容。

您好,谢谢您的回复。我同意您关于BDD的说法,但这只是一个草案示例,因为我的问题主要是关于如何在场景大纲的不同示例部分中使用datatable。也许使用您的示例,标题和历史记录将是一个用户看到的内容,但另一个用户将在另一个示例部分看到注释、详细信息和状态,但它们都在同一个场景大纲上。这就是我所说的第一页和第二页。如果我不是很清楚的话,也许可以闲聊一下?@FrancislainyCampos:他想告诉你,场景大纲是错误的工具。因为每个页面似乎处理不同的实体,所以它们应该是单独的场景。场景大纲旨在验证给定不同输入的相同行为。您正在测试不同的输入和不同的行为。嗨,谢谢。是的,我们在外面谈过,了解到我想用它来做什么,但用黄瓜似乎不太可能。