读取cumber中的.feature文件,并将内容复制到新的feature文件中

dw1jzc5e  于 2021-07-08  发布在  Java
关注(0)|答案(1)|浏览(337)

假设我在一个功能文件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中做到这一点?

4szc88ey

4szc88ey1#

也许你可以利用bdd发生器与qaf cucumber 。您应该在带有元数据过滤器的干运行模式下运行,生成的文件将只包含那些元数据(标记)的场景。bdd生成器从中编写的测试生成功能文件 .bdd , .feature 或者 .java 文件。如果需要,可以创建与bddgegenerator相同的自定义实现。

相关问题