私も同様の質問をしましたが、言葉遣いが悪く、求めていた回答が得られませんでした。別の試みを次に示します。
したがって、Cucumber の Gherkin Given ステートメントがテスト ケースの前提条件に類似していることに感謝します。これらはユーザーの操作を伴うべきではないと考える人がいることに感謝しますが、この質問のために、私はその見解に同意しません.
以下に 3 つのシナリオを示します。
Scenario: Test a song can be played
Given I setup a new account and default user
When I add a "2nd" user
And the "2nd" user starts playing a song
Then I should see a song is playing
Scenario: Test a playing song being stopped (version A)
Given I setup a new account and default user
And I add a "2nd" user
And the "2nd" user starts playing a song
When the "2nd" user stops playing a song
Then I should see a song is not playing
Scenario: Test a playing song being stopped (version B)
Given a "2nd" user is playing a song
When the "2nd" user stops playing a song
Then I should see a song is not playing
したがって、ビジネス ユーザーの観点からは、上記のバージョン B がバージョン A よりも優れていることを理解しています。ただし、コードの再利用の観点から見ると、バージョン B では、最初のシナリオの大部分で使用されたコードを繰り返すために、Given ステートメントが必要になることは間違いありません。 ?
乾杯、
チャーリー