我在编写测试场景时遇到问题,该测试场景检查将添加到数据库的站点的有效性。任何人都可以向我提供一个示例,说明如何正确编写它。不知怎的,我觉得'情景大纲'不是正确的方法......
'station'和'new_stations'是复杂的类型 我希望已经定义了'station',并检查是否可以添加每个'new_stations'。
Scenario Outline:
Given We have <stations>
And We are trying to add a station of the <new_stations> having the same id, the same name or the same code
Then we should not be able to add it
# <stations>
| Id | Code | Name | Validity |
| 1 | 1 | City 1 | from 2013-01-01 to 2013-04-01 |
| 2 | 2 | City 2 | from 2013-03-15 to 2013-05-01 |
# <new_stations>
| Id | Code | Name | Validity |
| 1 | 234 | City 4 | from 2013-03-01 to 2013-07-01 |
| 3 | 5 | City 1 | from 2013-03-01 to 2013-07-01 |
| 4 | 2 | City 3 | from 2012-03-15 to 2013-07-15 |
所以不应该添加'new_stations'
答案 0 :(得分:3)
我想你可能会混淆你的男人。
scenario outline用于描述相同的场景,但是以参数化的方式,以便依次注入值。这看起来像你的第二张表
但是你的例子读起来就像你需要为已知的工作站一次注入多行数据一样,所以它会成为(见tables)
Scenario Outline:
Given We have
| Id | Code | Name | Validity |
| 1 | 1 | City 1 | from 2013-01-01 to 2013-04-01 |
| 2 | 2 | City 2 | from 2013-03-15 to 2013-05-01 |
And We are trying to add a station <Id>, <Code>, <Name>, <Validity>
Then we should not be able to add it
Examples:
| Id | Code | Name | Validity |
| 1 | 234 | City 4 | from 2013-03-01 to 2013-07-01 |
| 3 | 5 | City 1 | from 2013-03-01 to 2013-07-01 |
| 4 | 2 | City 3 | from 2012-03-15 to 2013-07-15 |