Roman Bats
Roman Bats

Reputation: 1795

How to pass spaces in table (specflow scenario)?

How to pass spaces in table ?

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

Upvotes: 8

Views: 9252

Answers (3)

Alfonso Flores
Alfonso Flores

Reputation: 110

I just faced same situation, my solution was this, added spaces in the step as follows:

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 |

Upvotes: 0

perfectionist
perfectionist

Reputation: 4346

I would do this:

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

Then your bindings can be made to strip the quotes if present, but retaining the spaces.

I think this is much preferable to the idea of adding spaces afterward, because that isn't very human readable - quotations will make the spaces visible to the human (stakeholder / coder) reading them.

Upvotes: 13

Void Ray
Void Ray

Reputation: 10199

You can work around it by adding an extra step. Something like:

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

Edit:

A complete feature can look something like:

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>

Upvotes: 3

Related Questions