当前位置: 首页 > 知识库问答 >
问题:

Cucumber场景大纲-执行流

汝和裕
2023-03-14
@Login1
Feature: Title of your feature
  I want to use this template for my feature file

@Login1   `**SECTION ONE**`
Scenario Outline: Login into GMP Application
Given running indicator flag
And User is on GMP Application Login Screen
When User enters the in the Login
And User enters the in the password
And User clicks on the ok button
Then User logged in successful at Home Screen
Examples:
| atid   | pwd1    | runind |   -> Header
| nm1013 | test01g |   Y    |   -> TestCase1
| nm0313 | test02g |   Y    |   -> TestCase2

@Login1     `**SECTION TWO**`
Scenario Outline: Click on the Create Inquiry Menu Item
Given User is on GMP Home Screen
When user click on the Inquiry menu item
And select the billing mode should be
And user click create inquiry item from the heading
Then it should displays create inquiry pagef
Examples:
|   contract     |    -> Header
| GS00T07NSD0007 |    -> TestCase1
| GS00T07NSD0007 |    -> TestCase2

步骤定义

@Given(“running indicator flag (.*)”)
def run_indicator_flag(String ind1) {
println "Passing Indicator " + ind1
}

@And(“User is on GMP Application Login Screen”)
def user_on_GMP_Application_Login_Screen() {
boolean store2a
WebUI.openBrowser(’’)
WebUI.navigateToUrl(‘https://URL’, FailureHandling.STOP_ON_FAILURE)
}

@When(“User enters the (.*) in the Login”)
def user_enter_userid_in_the_Login(String uid) {
WebUI.setText(findTestObject(‘Object Repository/ORTC01/Page_/input_userid’), 
uid, FailureHandling.STOP_ON_FAILURE)
}

@And(“User enters the (.*) in the password”)
def User_enters_the_in_the_password(String pwd5) {
WebUI.setText(findTestObject(‘Object 
Repository/ORTC01/Page_/input_password’), pwd5, 
FailureHandling.STOP_ON_FAILURE)
}

共有1个答案

姬经义
2023-03-14

首先,您不能在Cucumber中连接场景。每个场景都是一个独立的测试,从零开始,做一些事情,然后重置为零。

其次,场景大纲只是以更紧凑的形式编写几个场景的一种方式。大纲中的每一组示例导致创建和运行单个场景。我强烈建议您避免使用场景大纲

好的场景描述了正在做的事情,而不涉及事情是如何做的。您的场景充满了事情是如何完成的,这使得它们变得复杂,并且非常难以处理。您应该将所有的HOW下推到您的步骤定义(或者更好的是步骤定义调用的helper方法)中。

Scenario: Create a billing enquiry
  Given I have a bill
  And I am logged in
  When I enquire about my bill
  Then ...
 类似资料:
  • 在我们的cucumber特性文件中,我们使用了场景大纲,在运行脚本之前,我们需要在运行时填充数据。 基于数据文件中传递的城市路线,我们使用一个API创建PNR,该API返回给我一个实际的PNR。创建的PNR值需要存储在场景数据表中。 如果我们有场景,我们可以使用DataTable函数访问函数内部的值。我们有任何类与场景大纲数据表交互吗 例如。 请让我知道如果现有的类或替代方案来解决这个问题。

  • 在我的cucumber jvm项目中,我希望在不使用场景大纲的情况下,使用相同的数据集执行场景10次(数据在excel中提供)。 有人能指导我如何做到这一点吗?

  • 有没有可能用gherkin写一个场景大纲,其中有一个断言步骤,而不是在所有的例子中都需要? null 有没有更好的写法?

  • 我的cucumber小cucumber看起来像这样: 在上面的功能中,有一个背景,它将为两个场景大纲中的每个示例执行。此外,在java实现中,我们已经实现了@After和@Before钩子,它们也将针对每个示例执行。 我们正在使用spring Cumber进行步骤之间的数据注入。 当第一个场景大纲中的所有示例结束时,调用@After实现的方法两次,就会出现问题。当第二次@After同时启动时,第二

  • 我一直在阅读大量的文档、帖子和文章,据说在单个功能文件中并行运行场景的开箱即用解决方案是不可能的。我们可以使用maven-surefire插件在不同的特性文件中并行运行,但不能在场景中运行。 例如,有一个包含场景的功能文件: 我想在单独的线程中同时运行所有这些场景。 我该如何实现这一点?