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 ""

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 "" AND I enter my ""

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用户

当−

它定义了任何测试场景执行的触发点。

例如,当我输入""

然后−

然后保存要执行的测试的预期结果。

例子-然后登录应该成功。

和−

它提供了任意两个语句之间的逻辑和条件。并且可以与GIVEN, WHEN和THEN连用。

例如,当我输入""和""时

但−

它表示任意两个语句之间的逻辑或条件。也可以与GIVEN, WHEN和THEN连用。

例子-然后登录应该成功。但是主页不应该丢失。

 

场景−

关于测试场景的细节需要在关键字“场景:”之后捕获。

例子−

场景:

假设我是Facebook用户

当我进入

我进入我的

然后登录应该成功。

但是主页不应该丢失。

 

背景−

背景通常有关于如何设置在每个场景运行之前的指令。但是,它在“Before”钩子之后执行(稍后讨论)。因此,当我们要设置web浏览器或建立数据库连接时,这是用于代码的理想选择。

例子−

背景:

转到Facebook主页。

 

 

场景大纲基本上用表中的值替换变量/关键字。表中的每一行都被认为是一个场景。
 

你可能感兴趣的:(cucumber)