2
我有一個針對3個不同標籤的功能。一些場景針對所有三個標籤運行,其中有兩個,一些針對一個。獲取命令行黃瓜標籤
@build_1 @build_2
Scenario: Test Case 1
Given I am on the home page
And I click the X button
Then I must see the text "function not available"
@build_1
Scenario: Test Case 2
Given I am on the home page
And I click the Y button
Then I must see the text "You pushed the Y button"
@build_2 @build_3
Scenario: Test Case 3
Given I am on the home page
And I click the Y button
Then I must see the text "function not available"
@build_3
Scenario: Test Case 4
Given I am on the home page
And I click the X button
Then I must see the text "Hey, this is neat!"
@build_1 @build_2 @build_3
Scenario: Test Case 5
Given I am on the home page
And I click the Z button
Then I must see the text "You pushed the Z button"
我運行使用三種不同的命令場景:給它需要建立有必要對我來說,運行測試,這種方式之間切換的時間
cucucmber features/my_test.feature --tags @build_1
cucucmber features/my_test.feature --tags @build_2
cucucmber features/my_test.feature --tags @build_3
我已經大大簡化了我的代碼。
有什麼方法可以告訴哪個標籤當前運行被調用?使用
scenario.source_tag_names
給出了給定場景的所有標記,我正在查找在命令行上指定的一個標記。如果我運行
cucucmber features/my_test.feature --tags @build_2
對於方案1,我得到
scenario.source_tag_names = ["@build_1", "@build2", "@build_3"]
我想要的東西,只是給@ build_2。
最後我在尋找的是確保所有場景都針對它們各自的標籤運行的方法。
你爲什麼要這麼做?你擔心這種情況不會發生嗎? –
說實話,這是一個非常複雜的系統,其中超過一百個測試將運行超過30個配置(我使用術語「構建」來簡化問題)。我認爲知道我的測試應該運行多少種配置,並且它是否真的在其上運行,這將是明智的簿記。 –
在這種情況下,你可能會存儲測試結果,然後grep他們的計數。 –