8

如何在表格中传递空格?

Background:
    Given the following books
        |Author         |(here several spaces)Title(here several spaces)|
4

3 回答 3

12

我会这样做:

Given the following books
| Author              | Title               |
| "J. K. Rowling"     | "Harry P     "      |
| " Isaac Asimov   "  | "Robots and Empire" |

然后可以进行绑定以去除引号(如果存在),但保留空格。

我认为这比在之后添加空格的想法更可取,因为这不是人类可读的 - 引用将使阅读它们的人(利益相关者/编码人员)可以看到空格。

于 2012-10-02T16:31:46.410 回答
3

您可以通过添加一个额外的步骤来解决它。就像是:

Given the following books
|Author         | Title |
Add append <5> spaces to book title

编辑:

一个完整的功能可能类似于:

Scenario: Adding books with spaces in the title
Given the following book
| price | title |
And <5> spaces appended to a title
When book is saved
Then the title should be equals to <title without spaces>
于 2012-10-01T17:58:45.047 回答
0

我刚遇到同样的情况,我的解决方案是这样,在步骤中添加空格如下:

Scenario: Adding books with spaces in the title
Given the following book '    <title>    '
When book is saved
Then the title should be equals to '<title>'
| price | title        |
| 50.00 | Working hard |

于 2020-08-07T17:25:43.850 回答