当我有不同数量的参数时如何在 Gherkin 中使用场景大纲

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

我对 Playwright 和 Gherkin 相当陌生,我正在尝试在我的一项测试中实现场景大纲,因为步骤基本相同。但是,当我需要在一个步骤中检查多个值时,我遇到了验证问题。为了澄清这一点,这是我的场景设置:

Background:
  Given I am "user"
  And I am logged in
  And I am on the "content-management" page

Scenario Outline: As a User, I want to be able to upload, import and export an environment containing unsupported entities
        When I upload files:
            | Name        |
            | <file_name> |
        Then I should see record with parameters:
            | Name   | Content Description   | Source Environment | Source Version
            | <Name> | <Content Description> | <Source Env>       | <Source Ver> |
        And I can find parent log message "<upload_log_message>"
        When I import environment with properties:
            | Property  | Value |
            | Activate  | Yes   |
            | Overwrite | No    |
        And I can confirm import
        Then I should see notification "Successfully imported the environment"
        And I can find parent log message "Env '<envID>/<envVer>': Import process completed in"
        And I can find child log message '<import_child_log>'
**EXAMPLES:**
 | file_name | Name  | Content Description |upload_log_message |import_child_log
 | ABC       | ABC   | ABC                 | ABC               | ABC <DEF> <GHI>

我的问题是关于 import_child_log 参数。我想在此参数中使用多个值(例如,多个占位符,如 , )。这可能吗?如果可以,如何实施?

我尝试使用逗号(,)或分号(;)作为分隔符,但它不起作用。在执行过程中,它将其读取为单个字符串,如 ABC、DEF、GHI...

javascript testing playwright gherkin
1个回答
0
投票

因为

import_child_log
列值是一个字符串。使用
split(',')

或者在示例中使用 3 行

| file_name | Name  | Content Description |upload_log_message |import_child_log
| ABC       | ABC   | ABC                 | ABC               | ABC
| ABC       | ABC   | ABC                 | ABC               | DEF
| ABC       | ABC   | ABC                 | ABC               | GHI
© www.soinside.com 2019 - 2024. All rights reserved.