簡體   English   中英

運行黃瓜測試更改變量?

[英]Running cucumber test changing variables?

請允許我向您展示我在學校平台上進行的測試中的一小段代碼:

  Background:
    I Enter the school page
    In Schools I navigate to:
      | Hierarchical level | Action      | Value          |
      | District           | expand      | District-A     |
      | School             | right click | Saint John's   |
    And Choose "Go to" on the Popup Menu
    And Zoom In To See More Options in Control Bar

因此,您看到了,我使用這種背景來瀏覽網站上的一棵小樹。 我的問題是,我可以代替“ District-A”和“ Saint John's”這兩個變量嗎,例如“ district”和“ school”,這樣我可以在命令行上運行測試時就像一個額外的參數這樣說:我希望這一輪測試將我的“區”設置為“區B”,並讓“學校”變量成為學校之一。 首先,這有可能嗎? 其次,如果可以的話,有人可以給我一個快速的想法,讓我知道如何做嗎?

提前非常感謝您-

在黃瓜中,您編寫了一些方案來描述您要嘗試做的事情,並可能解釋其重要性的原因。 您不應編寫解釋您如何做某事的步驟。 任何有關單擊,擴展等的步驟最終都會導致出現您遇到的問題。

因此,第一件事是描述此背景要實現的目標以及其重要性。 在考慮如何操作之后,將其下推到步驟定義和輔助方法中。 完成此操作后,您可能會遇到類似

Scenario: View a school
  Given there is a school
  When I view the school
  Then I should see the school

現在,這似乎很簡單,但這就是重點。 您應該使您的網站易於使用。 因此,您需要做的第一件事就是能夠看到一所學校。 完成此操作后,您可能想要處理很多學校,並考慮考慮尋找一所特定的學校。 然后,您可能會遇到類似

Feature: Search for a school
  We want to be able to find a particular school

Scenario: Find a school
  Given there are lots of schools with one searchable
  When I search for the school
  Then I should see search results with one school

您可能會與地區類似

Feature: Districts
  Schools are organised by districts. We would like to view all the schools in a district

  Scenario: View district
    Given there is a district
    When I view the district 
    Then I should see the district

  Scenario: See schools in a district
    Given there is a district
    And the district has some schools
    When I view the district
    Then I should see some schools

等等 ...

請注意,這些方案在頁面,單擊等方面完全沒有任何作用。其全部內容和原因而不是方式。 還要注意,一切都簡單得多。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM