【问题标题】:Read .feature file in cucumber and copy content to new feature file读取黄瓜中的 .feature 文件并将内容复制到新的功能文件中
【发布时间】:2020-11-23 19:53:39
【问题描述】:

假设,我在 1 个功能文件下有许多场景 - GamePlay.feature

Feature: Game play

@TestCase_1 @Regression
 Scenario: Breaker joins a game
    Given the Maker has started a game with the word "silky"
    When the Breaker joins the Maker's game
    Then the Breaker must guess a word with 5 characters

@TestCase_2 @Regression 
 Scenario: Breaker joins a game
    Given the Maker has started a game with the word "soft"
    When the Breaker joins the Maker's game
    Then the Breaker must guess a word with 4 characters

.
.
. and many more

假设我想复制测试用例 #2(Scenario、Given、When、Then)的测试步骤并将它们粘贴到新的功能文件中(GameLost.feature)。 我将根据标签搜索场景(例如 -@TestCase_2) 新的功能文件 GameLost.feature 应该看起来像 -

Feature: Game lost

@TestCase_2 @Regression 
 Scenario: Breaker joins a game
    Given the Maker has started a game with the word "soft"
    When the Breaker joins the Maker's game
    Then the Breaker must guess a word with 4 characters

我如何在 Java 中做到这一点?

【问题讨论】:

  • 有什么建议吗?

标签: java parsing cucumber gherkin feature-file


【解决方案1】:

也许您可以通过qaf-cucumber 受益于bdd generator。您应该使用元数据过滤器在空运行模式下运行,并且生成的文件将仅包含那些元数据(标签)的场景。 BDD 生成器根据您在.bdd.feature.java 文件中编写的测试生成功能文件。如果需要,您可以创建与 BDDGenerator 相同的自定义实现。

【讨论】:

    猜你喜欢
    • 2021-03-16
    • 1970-01-01
    • 1970-01-01
    • 2018-04-23
    • 1970-01-01
    • 1970-01-01
    • 2022-08-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多