5

Specflow、Selenium WebDriver、および C# を使用して、次のテストを行いました。

Scenario Outline: Verify query result
    Given I'm logged in
    When I enter "<query>"
    Then I should see the correct result

    Examples: 
    | query  |
    | Query1 |
    | Query2 |
    | Query3 |

各シナリオの後、ScenarioContext.Current.ScenarioInfo.Title に基づいて名前が付けられたファイルにスクリーンショットを保存します。ただし、繰り返しを区別する良い方法が見つからないため、スクリーンショットが上書きされます。例の表に列を追加することもできますが、より一般的な解決策が必要です...

どの反復が実行されているかを知る方法はありますか?

4

3 に答える 3

0

シナリオで定義していない限り、名前は表示されません。あなたの機能はこのように書くことができます

  Scenario Outline: Performing mathematical operation
    Given I am on <name> scenario
    And I have entered <first> into the calculator
    And I have entered <last> into the calculator
    When I do the <operation> 
    Then the result should be <result> on the screen
Examples: 
| name   | first | last | result | operation |
| simple | 1     | 1    | 2      | add       |
| subs   | 6     | 2    | 4      | substract |

上記の構造化の利点は、同じシナリオを活用して、「加算」、「減算」、「乗算」などの複数の操作を実行できることです。

于 2018-01-23T22:57:33.643 に答える