cucumber註解

 

Given −

It describes the pre-requisite for the test to be executed.

Example − GIVEN I am a Facebook user

When −

It defines the trigger point for any test scenario execution.

Example − WHEN I enter "<username>"

Then −

Then holds the expected result for the test to be executed.

Example − THEN login should be successful.

And −

It provides the logical AND condition between any two statements. AND can be used in conjunction with GIVEN, WHEN and THEN statement.

Example − WHEN I enter my "<username>" AND I enter my "<password>"

But −

It signifies logical OR condition between any two statements. OR can be used in conjunction with GIVEN, WHEN and THEN statement.

Example − THEN login should be successful. BUT home page should not be missing.

Scenario −

Details about the scenario under the test needs to be captured after the keyword “Scenario:”

Example −

Scenario:

GIVEN I am a Facebook user

WHEN I enter my

AND I enter my

THEN login should be successful.

BUT home page should not be missing.

 

Background −

  • Background generally has the instruction on what to setup before each scenario runs. However, it gets executed after “Before” hook (to be covered later). So this is ideal to be used for code when we want to set up the web-browser or we want to establish the database connectivity.

    • Example −

      Background:

      Go to Facebook home page.

 

 

Cucumber - Scenario Outline

Scenario outline basically replaces variable/keywords with the value from the table. Each row in the table is considered to be a scenario

 

對應漢文意思:

鑑於−

它描述了執行測試的先決條件。

舉例來說,我是一個Facebook用戶

當−

它定義了任何測試場景執行的觸發點。

例如,當我輸入"<username>"

然後−

然後保存要執行的測試的預期結果。

例子-然後登錄應該成功。

和−

它提供了任意兩個語句之間的邏輯和條件。並且可以與GIVEN, WHEN和THEN連用。

例如,當我輸入"<username>"和"<password>"時

但−

它表示任意兩個語句之間的邏輯或條件。也可以與GIVEN, WHEN和THEN連用。

例子-然後登錄應該成功。但是主頁不應該丟失。

 

場景−

關於測試場景的細節需要在關鍵字“場景:”之後捕獲。

例子−

場景:

假設我是Facebook用戶

當我進入

我進入我的

然後登錄應該成功。

但是主頁不應該丟失。

 

背景−

背景通常有關於如何設置在每個場景運行之前的指令。但是,它在“Before”鉤子之後執行(稍後討論)。因此,當我們要設置web瀏覽器或建立數據庫連接時,這是用於代碼的理想選擇。

例子−

背景:

轉到Facebook主頁。

 

 

場景大綱基本上用表中的值替換變量/關鍵字。表中的每一行都被認爲是一個場景。
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章