cucumber JVM:如何在before hook中运行另一个功能的场景

时间:2015-03-02 09:34:32

标签: cucumber

我有一个功能文件,其中包含在某个工具中创建回购的方案。出于安全原因,我已将某些项目注释掉了。这并不重要。

  • @CreateRepo方案测试创建回购的步骤
  • @CreateBranch方案测试创建分支的步骤
  • 如下所示,@CreateBranch在创建回购的方案开始时重复所有相同的步骤。它看起来很难看,并且重复了一些步骤。

  • 我希望能够在CreateBranch的步骤defs文件中的before hook中运行@CreateRepo,而不必复制创建repo的所有相同步骤。 这可能吗?


功能文件1:

  Feature: Create a repository in {hidden}

  Background:
    Given I sign into {hidden} on 'node1' as the 'root' user using password: 'password'

  @CreateRepo
  Scenario: Administrator creates a new repository through {hidden} UI.
    When I click on the {hidden} icon on the Navigation bar
    Then I should be on the {hidden} page
    When I create a public project called {hidden}
    Then the repo {hidden} should be {hidden content}
    Then On 'node1' I follow the steps for creating a new repository
    When I clone {hidden} to 'node2'
    Then I check {hidden} on 'node2' has branch 'master'**

功能文件2:

Feature: Create a branch for a project in {hidden}
    @CreateBranch
    Scenario: Administrator creates a new repository through {hidden} UI.
    When I click on the {hidden} icon on the Navigation bar
    Then I should be on the {hidden} page
    When I create a public project called {hidden}
    Then the repo {hidden} should be {hidden content}
    Then On 'node1' I follow the steps for creating a new repository
    When I clone {hidden} to 'node2'
    Then I check {hidden} on 'node2' has branch 'master'**
    When I click on the '{hidden}' link
    And I click on the '{hidden}' link
    When I select '{hidden}' from the {hidden} list
    And I click on the '{hidden}' for {hidden} button
    When I click the '{hidden}' button on {hidden} page
    Then I should be on the '{hidden}' page

要素文件2的步骤定义文件:

@Before("@CreateBranch")
public static void beforeCreateBranch() throws Exception{

  //Run @CreateRepo scenario somehow...

}

0 个答案:

没有答案