3.5. Step - 05 : Tabulated entries¶
Now let’s add tests with a table of entries:
# For repeated parameters,
# we can use table
Feature: Tabulated maths
Scenario Outline: Addition of single digit numbers
Given I have '<num1>' and '<num2>'
When I add them
Then The result must be '<total>'
Examples:
| num1 | num2 | total |
| 1 | 2 | 3 |
| 10 | 20 | 30 |
| 22 | 33 | 55 |
| 22 | 33 | 55 |
Now, the file/folder structure looks like this:
.
|-- features
| |-- steps
| | `-- steps_addition.py
| |-- environment.py
| |-- simple-addition.feature
| `-- table-addition.feature
`-- libmath.py
With above contents, if we run behave:
behave --no-timings --no-source
We can see more tests are added… and everything is successful:
Feature: Simple Addition
Showcase simple addition for the BDD Book.
Scenario: Addition of single digit numbers
Given I have '1' and '3'
When I add them
Then The result must be '4'
Scenario: Addition of double digit numbers
Given I have '70' and '29'
When I add them
Then The result must be '99'
Feature: Tabulated maths
Scenario Outline: Addition of single digit numbers -- @1.1
Given I have '1' and '2'
When I add them
Then The result must be '3'
Scenario Outline: Addition of single digit numbers -- @1.2
Given I have '10' and '20'
When I add them
Then The result must be '30'
Scenario Outline: Addition of single digit numbers -- @1.3
Given I have '22' and '33'
When I add them
Then The result must be '55'
Scenario Outline: Addition of single digit numbers -- @1.4
Given I have '22' and '33'
When I add them
Then The result must be '55'
2 features passed, 0 failed, 0 skipped
6 scenarios passed, 0 failed, 0 skipped
18 steps passed, 0 failed, 0 skipped, 0 undefined
Took 0m0.002s