在黄瓜示例表中传递POJO [英] Pass POJOs in Cucumber Example table

查看:61
本文介绍了在黄瓜示例表中传递POJO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说明:作为测试开发人员,我想使用一个场景来测试3种不同的环境.

Description: As a test developer, I would like to use a single scenario to test 3 different environments.

简化方案示例:

  @smoke
  Scenario: Login to the login page and assert that the user is logged in
    Given User navigates to the page
    And User enters valid login credentials
    When User clicks on the login button
    Then Landing page can be seen

数据(这些是从属性文件中获取的-转换为POJO):

Data ( These are grabbed from a property file - converted to POJO ) :

Env1.class
url = www.environment1.com
username = john
password = doe1

Env2.class
url = www.environment2.com
username = john2
password = doe2

Env2.class
url = www.environment3.com
username = john3
password = doe3

测试设置

  1. 每个环境都有自己的测试运行器(failsafe)
  2. 每个环境并行运行.
  3. 运行测试,并通过〜mvn clean verify
  4. 构建
  5. 随着环境的变化,测试取决于属性文件.

可能的解决方案:有没有办法在示例表中传递POJO?或黄瓜的数据表?

Potential solution: Is there a way to pass POJOs in the Example Table? or Cucumber's data table?

我是BDD和Cucumber的新手-任何帮助都将是很大的.谢谢.

I am new to BDD and Cucumber - any help would be great. Thank you.

TLDR:是否可以在黄瓜示例表中传递Prop File变量?

TLDR: is there a way to pass the Prop File variable in the Examples Table in Cucumber?

| URL | Username | Password | 
| env1.getUrl | env1.getUsername | env1.getPassword |

所以会是

 @smoke
  Scenario: Login to the login page and assert that the user is logged in
    Given User navigates to the page <URL>
    And User enters valid login credentials <Username> and <Password>
    When User clicks on the login button
    Then Landing page can be seen

推荐答案

您可以使用方案纲要来运行同一方案,并为每次运行提供不同的数据.但这不会是平行的.它是顺序的.功能文件是

You can use the scenario outline to run the same scenario with different data for each run. But it will be not parallel. It is sequential. The feature file is,

  @smoke
  Scenario Outline: Login to the login page and assert that the user is logged in
    Given User navigates to the page <URL>
    And User enters valid login credentials <Username> and <Password>
    When User clicks on the login button
    Then Landing page can be seen
  Example:
  |URL                 |UserName|Passowrd|
  |www.environment1.com|john1   |doe1    |
  |www.environment2.com|john2   |doe2    |    
  |www.environment2.com|john3   |doe3    |

您可以使用单个跑步者课程.无需使用属性文件或pojo类.

You can use a single runner class. No need to use either property file nor pojo class.

这篇关于在黄瓜示例表中传递POJO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆