3

データベースに追加されるステーションの有効性をチェックするテストシナリオの作成に問題があります。誰かがそれを正しく書く方法を示す例を私に提供できますか?どういうわけか、「シナリオの概要」は正しい方法ではないと感じています...

「stations」と「new_stations」は複雑なタイプです。「stations」をすでに定義して、それぞれに「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」は追加しないでください

  • Id 1は、そのIDが一意ではないため
  • 名前が一意ではないため、ID 3
  • コードが一意ではないため、ID 4
4

1 に答える 1

3

私はあなたがあなたの多くを混同しているかもしれないと思います。

シナリオの概要は、同じシナリオを説明するために使用されますが、値が順番に挿入されるようにパラメーター化された方法で使用されます。それはあなたが持っている2番目のテーブルのように見えます

しかし、あなたの例は、既知のステーションに対して一度に多くの行のデータを注入する必要があるように読めます。そのため、次のようになります(を参照) 。

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 | 
于 2013-02-21T11:46:42.857 に答える